3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ '', 3445, '', 3446, '', 3452, '', 3530, 3555, ]; $str = serialize($arr); echo $str; // a:9:{i:0;s:0:"";i:1;i:3445;i:2;s:0:"";i:3;i:3446;i:4;s:0:"";i:5;i:3452;i:6;s:0:"";i:7;i:3530;i:8;i:3555;} echo PHP_EOL; $arr = unserialize($str); print_r($arr); // Array ( [0] => [1] => 3445 [2] => [3] => 3446 [4] => [5] => 3452 [6] => [7] => 3530 [8] => 3555 ) echo PHP_EOL; $arrayLen = count($arr); echo 'array length : ' . $arrayLen; // 9 echo PHP_EOL; // return index of value $needle = 3452; $index = array_search($needle, $arr); echo 'found value ' . $needle . ' at index : ' . $index; // found value 3452 at index 5 echo PHP_EOL; // Count only non empty array entries $arrNonEmpty = array_filter($arr, function($element) { return !empty($element); }); $count = count($arrNonEmpty); echo 'non empty values in array : ' . $count; echo PHP_EOL; print_r($arrNonEmpty); // rebase array indices $arrNonEmpty = array_values($arrNonEmpty); echo 'rebased indices:' . PHP_EOL; print_r($arrNonEmpty);
Output for git.master, git.master_jit, rfc.property-hooks
a:9:{i:0;s:0:"";i:1;i:3445;i:2;s:0:"";i:3;i:3446;i:4;s:0:"";i:5;i:3452;i:6;s:0:"";i:7;i:3530;i:8;i:3555;} Array ( [0] => [1] => 3445 [2] => [3] => 3446 [4] => [5] => 3452 [6] => [7] => 3530 [8] => 3555 ) array length : 9 found value 3452 at index : 5 non empty values in array : 5 Array ( [1] => 3445 [3] => 3446 [5] => 3452 [7] => 3530 [8] => 3555 ) rebased indices: Array ( [0] => 3445 [1] => 3446 [2] => 3452 [3] => 3530 [4] => 3555 )

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:
132.31 ms | 407 KiB | 5 Q