3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = ['a','b','c','title1','d','e','f','title2','g','h','title3','i','title4','j','k']; $batch = 0; // default value foreach ($myArray as $v) { if (strpos($v, 'title') !== 0) { // value is NOT a "title#"" string $result[$batch][] = $v; // save with current batch value as 1st level key } else { $batch = $v; // update batch value with "title#" string } } var_export($result);
Output for rfc.property-hooks, git.master_jit, git.master
array ( 0 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), 'title1' => array ( 0 => 'd', 1 => 'e', 2 => 'f', ), 'title2' => array ( 0 => 'g', 1 => 'h', ), 'title3' => array ( 0 => 'i', ), 'title4' => array ( 0 => 'j', 1 => 'k', ), )

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:
48.49 ms | 1541 KiB | 4 Q