3v4l.org

run code in 300+ PHP versions simultaneously
<?php // note the const declarations -- constants really read-only vars const COMMA = ','; const EMPTY_STR = ""; const NULL_CHAR = "\0"; $delim = '\n'; // note what happens when inserted into doubled-quoted string $data = "1,2,3,$delim,4,5,6,$delim,7,8,9"; echo "\nThe data is:\n\n$data\n\n"; var_dump( EMPTY_STR, NULL_CHAR,strcmp(EMPTY_STR, NULL_CHAR)); // "" != "\0" and "" !== "\0" echo "Is null char empty value? ",empty(NULL_CHAR)? 'true':'false',"\n"; echo "Is zero an empty value? ",empty(0)? 'true':'false',"\n"; $strNumsEtc = str_replace( COMMA, EMPTY_STR, $data); echo "\nResult: $strNumsEtc\n"; $strArr = explode( $delim, $strNumsEtc); var_dump(str_split($strNumsEtc,3)); foreach ($strArr as $str) { echo $str,PHP_EOL; // echo print both shades of echo: echo multiple vars, print one var plus retval } // must add the PHP_EOL since PHP doesn't automatically do this echo PHP_EOL; foreach ($strArr as $str) { print $str; print PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
The data is: 1,2,3,\n,4,5,6,\n,7,8,9 string(0) "" string(1) "" int(-1) Is null char empty value? false Is zero an empty value? true Result: 123\n456\n789 array(5) { [0]=> string(3) "123" [1]=> string(3) "\n4" [2]=> string(3) "56\" [3]=> string(3) "n78" [4]=> string(1) "9" } 123 456 789 123 456 789

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:
45.01 ms | 402 KiB | 8 Q