3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getAllWholeWordPos($s,$word){ $b = " "; $delimited = "$b$word$b"; $retval = false; for ($i=0, $max = strlen( $s ); $i < $max; $i++) { if ( !ctype_alpha( $s[$i] ) ){ $s[$i] = $b; } } while ( ( $pos = stripos( $s, $delimited) ) !== false ) { $retval[] = $pos + 1; for ( $i=0, $max = $pos + 1 + strlen( $word ); $i <= $max; $i++) { $s[$i] = $b; } } return $retval; } $whole_word = "any"; $str = "Will *$whole_word* company do *$whole_word* job, (are there $whole_word)?"; echo "\nString: \"$str\""; $result = getAllWholeWordPos( $str, $whole_word ); $times = count( $result ); echo "\n\nThe word \"$whole_word\" occurs $times times:\n"; foreach ($result as $pos) { echo "\nPosition: ",$pos; }
Output for git.master, git.master_jit, rfc.property-hooks
String: "Will *any* company do *any* job, (are there any)?" Deprecated: Automatic conversion of false to array is deprecated in /in/ZEoZe on line 15 The word "any" occurs 3 times: Position: 6 Position: 23 Position: 44

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.64 ms | 405 KiB | 5 Q