Two points have to be noted here:
1. if you use else if conditional loop then it will go for only on condition for your input,then other matched inputs will not return strings.
2.decide your input manner, whether it is in comma separated or space separated or some thing else. Based on this explode an array called $programs using php explode function.
and also:
-> Use in_array() instead of array_search for searching string in an array.
-> remove while loop, no use here.
based on the above things i have changed your code accordingly.try with the following:
<?php
function check_programs($input)
{
$programs = explode(" ", $input);
$return_string = '';
if(in_array('ma', $programs) == true){
$return_string .= "Maya, ";
}if(in_array('ps', $programs) == true){
$return_string .= "Photoshop, ";
}if(in_array('ai', $programs) == true){
$return_string .= "Illustrator, ";
}if(in_array('xn', $programs) == true){
$return_string .= "xNormal, ";
}
if(in_array('mm', $programs) == true){
$return_string .= "MatchMover, ";
}
return $return_string;
}
echo $string1=check_programs('ps xn');
?> If your requirement not matches this come up with clear information.
thanks.