3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen_explode($delimiter, $string, $limit=NULL) { $offset = 0; $count = 0; $dlen = strlen($delimiter); $len = strlen($string); while( ($pos = strpos($string, $delimiter, $offset)) !== false ) { if( !is_null($limit) && $count++ >= $limit ) { return; } yield substr($string, $offset, $pos-$offset); $offset = $pos + $dlen; } if( $offset == $len ) { yield ''; // replicate explode() empty trailing groups } else if( $offset < $len ) { yield substr($string, $offset); } } $input = "1||50||£---2||25||£---3||25||£---"; foreach( gen_explode('---', $input, 3) as $piece ) { var_dump($piece); foreach( gen_explode('||', $piece) as $smaller_piece ) { var_dump($smaller_piece); } }
Output for git.master, git.master_jit, rfc.property-hooks
string(9) "1||50||£" string(1) "1" string(2) "50" string(2) "£" string(9) "2||25||£" string(1) "2" string(2) "25" string(2) "£" string(9) "3||25||£" string(1) "3" string(2) "25" string(2) "£" string(0) "" string(0) ""

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.74 ms | 401 KiB | 8 Q