3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['id' => 0, 'name' => '10sdf'], ['id' => 0, 'name' => '12'], ['id' => 0, 'name' => 'aasdfbc'], ['id' => 0, 'name' => 'ada'], ['id' => 0, 'name' => 'asdfsdf'], ]; //排序 usort($arr, function ($a, $b) { if (strlen($a['name']) == strlen($b['name'])) return 0; return strlen($a['name']) < strlen($b['name']) ? -1 : 1; }); //修改key $keys = array_keys($arr); array_walk($keys, function (&$v){ $v +=1; }); $arr1 = array_combine($keys, $arr); var_dump($arr1);
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { [1]=> array(2) { ["id"]=> int(0) ["name"]=> string(2) "12" } [2]=> array(2) { ["id"]=> int(0) ["name"]=> string(3) "ada" } [3]=> array(2) { ["id"]=> int(0) ["name"]=> string(5) "10sdf" } [4]=> array(2) { ["id"]=> int(0) ["name"]=> string(7) "aasdfbc" } [5]=> array(2) { ["id"]=> int(0) ["name"]=> string(7) "asdfsdf" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
70.71 ms | 402 KiB | 8 Q