I’m trying to find the best way to find a value in an array:
The value of $this->school_degree is retrieved from the Facebook Graph API. For the sake of this example, its value could be any (but only one of the following):
- Masters of Science in Computer Science
- Masters in Computer Science
- Computer Science
- MBA
So my natural inclination was to do this:
function EXPLODETEST () {
$explode_degree = explode(" ", $this->school_degree);
echo "$explode_degree[0]";
echo "$explode_degree[1]";
echo "$explode_degree[2]";
echo "$explode_degree[3]";
echo "$explode_degree[4]";
echo "$explode_degree[5]";
echo "$explode_degree[6]";
}
At which point I’d have to create a really long if or statement to search each offset for the words computer science.
The endgame is to echo one statement if they’re mastering in CS and echo another statement if they’re not. What is the best way to go about this?
If the degree always contains the words “Computer Science” could you not just search for that text in the string?