$string = 'Ma';
$arr1 = str_split($string);
foreach($arr1 as $a)
{
echo $a."<br>";
}
$os = array("Mac", "NT", "Irix", "Linux", "apple");
Here I have some strings in $string variable. In this line echo $a."<br>"; it returns this result
M
a
it splits the string. Now I want to find the words (array("Mac", "NT", "Irix", "Linux", "apple");) with these splited string (M a). For example, My string is Ma, First I want to find the string in an array which string starting with M and next I want to find another string in an array which string with a. Then I want to echo those both strings. Results should be Mac apple. How do I get it?
foreach($arr as $item) { if (substr($item, 0, 1) == 'M') { found_it(); }}