3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "I am a boy like desired and expected"; for ( $offset = 0, $length = strlen($string); $offset < $length; ++$offset ) { $offset += $string[$offset] === ' '; echo "word at offset $offset, call strpos()\n"; for ( $swaps = 0, $wordEnd = (strpos($string, ' ', $offset) ?: $length) - 1; $offset < $wordEnd; ++$swaps, ++$offset, --$wordEnd ) { [$string[$wordEnd], $string[$offset]] = [$string[$offset], $string[$wordEnd]]; echo "$offset : $wordEnd : $swaps : $string\n"; } $offset += $swaps; } echo $string;
Output for git.master, git.master_jit, rfc.property-hooks
word at offset 0, call strpos() word at offset 2, call strpos() 2 : 3 : 0 : I ma a boy like desired and expected word at offset 5, call strpos() word at offset 7, call strpos() 7 : 9 : 0 : I ma a yob like desired and expected word at offset 11, call strpos() 11 : 14 : 0 : I ma a yob eikl desired and expected 12 : 13 : 1 : I ma a yob ekil desired and expected word at offset 16, call strpos() 16 : 22 : 0 : I ma a yob ekil desired and expected 17 : 21 : 1 : I ma a yob ekil desired and expected 18 : 20 : 2 : I ma a yob ekil derised and expected word at offset 24, call strpos() 24 : 26 : 0 : I ma a yob ekil derised dna expected word at offset 28, call strpos() 28 : 35 : 0 : I ma a yob ekil derised dna dxpectee 29 : 34 : 1 : I ma a yob ekil derised dna depectxe 30 : 33 : 2 : I ma a yob ekil derised dna detecpxe 31 : 32 : 3 : I ma a yob ekil derised dna detcepxe I ma a yob ekil derised dna detcepxe

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:
26.26 ms | 408 KiB | 5 Q