Last active
December 14, 2015 07:48
-
-
Save reactormade/5052806 to your computer and use it in GitHub Desktop.
Extract a string from an array of string if it matches to a another string (comparison)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extract_matching_string_from_array($array_of_strings, $comparison){ | |
$array = array(); | |
foreach ($array_of_strings as $string): | |
if (strstr($string, $comparison)): | |
array_push($array, $string); | |
endif; | |
endforeach; | |
return $array; | |
} | |
//$another = extract_matching_string_from_array($string, 'something-to-compare'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment