|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-10-24 06:22 UTC] yohgaki@php.net
-Summary: Better things handling
+Summary: Better things handling - basic variables should
behave like object, etc
[2015-05-28 10:21 UTC] cmb@php.net
[2018-02-27 11:25 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2018-02-27 11:25 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Description: ------------ I would really like to have something like a better handling of array, strings, numbers and so on. Look at my examples, you will understand better what i mean Test script: --------------- <?php $a = [2, 3, 4, 5]; // I define an array as for php 5.4 $a = $a->map(function($el) { // $a = array_map(callback, $a); return $el +1; }); $b = "Hello"; $b = $b->substr(0, -1); // $b = substr($b, 0, -1); $c = [2, 3]; $c = $c->merge([4, 5]); // $c = array_merge($c, [4, 5]); $d = 22 + [2, 3, 4, 5, 6]; // $d = 22 + 2 + 3 + 4 + 5 + 6 $a[] = $b; $a[] = $c; $a[] = $d; // i also would like to have a built-in swap function like this: $a->swap($b); // $a is $b and $b is $a Expected result: ---------------- $a should be [3, 4, 5, 6, "Hell", [2, 3, 4, 5], 42]; $b should be "Hell"; $c should be [2, 3, 4, 5]; $d should be The answer to universe, life and everything; // 42