3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function endswith($string, $test) { $strlen = strlen($string); $testlen = strlen($test); if ($testlen > $strlen) return false; return substr_compare($string, $test, -$testlen) === 0; } if(false == endswith('http://localhost/events/10','/events/')){ echo "true\n"; } else{ echo "false\n"; } $testlen = strlen('/bob/'); if(false == (substr_compare('http://localhost/events/10','/events/',-$testlen)===0)){ echo "true\n"; } else{ echo "false\n"; } $url = 'http://192.168.1.0/events/10'; preg_match_all('^\d+^',$url,$matches,PREG_PATTERN_ORDER); $arraylen = count($matches); for($x=0;$x<$arraylen;$x++){ $array3len = count($matches[$x]); for($z=0;$z<$array3len;$z++){ echo $matches[$x][$z]."\n"; } }
Output for 5.0.0 - 5.5.10, 5.5.12 - 7.1.0
true true 192 168 1 0 10
Output for 5.5.11
false false 192 168 1 0 10
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: substr_compare() in /in/MWY2R on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: substr_compare() in /in/MWY2R on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: substr_compare() in /in/MWY2R on line 8