3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_str_contain($string, $keyword){ if(empty($string) || empty($keyword)) return false; $keyword_first_char = $keyword[0]; $keyword_length = strlen($keyword); $string_length = strlen($string); if( $string_length < $keyword_length ) return false; if( $string_length == $keyword_length ){ if($string == $keyword) return true; else return false; } if($keyword_length > 1){ for( $i=0; $i < $string_length; $i++){ //check if keyword's first char == string's first char if( $keyword_first_char == $string[$i] ){ $match = 1; for($j = 1; $j < $keyword_length; $j++){ if( ($i+$j < $string_length) && $keyword[$j] == $string[$i+$j] ){ $match++; } } if($match == $keyword_length){ return true; } } } } if($keyword_length == 1){ for( $i=0; $i < $string_length; $i++){ //check if keyword's first char == string's first char if( $keyword_first_char == $string[$i] ){ return true; } } } return false; } var_dump(is_str_contain("test", "t")); //true var_dump(is_str_contain("test", "")); //false var_dump(is_str_contain("test", "test")); //true var_dump(is_str_contain("test", "testa")); //flase var_dump(is_str_contain("a----z", "a")); //true var_dump(is_str_contain("a----z", "z")); //true
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) bool(false) bool(true) bool(false) bool(true) bool(true)

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:
38.05 ms | 401 KiB | 8 Q