strstr() and stristr() with Arrays

<?php

function strstr_array( $haystack, $needle ) {
if ( !is_array( $haystack ) ) {
return false;
}
foreach ( $haystack as $element ) {
if ( strstr( $element, $needle ) ) {
return $element;
}
}
}

function stristr_array( $haystack, $needle ) {
if ( !is_array( $haystack ) ) {
return false;
}
foreach ( $haystack as $element ) {
if ( stristr( $element, $needle ) ) {
return $element;
}
}
}

?>

source

Leave a Reply