I'm reading an RTF file that gets uploaded by the user, I then exploded this file on each \pard to get each line and then preg_split each line into an array. I then loop over the array looking for a certain value and get the data next to it. All this is working fine but what's the best way to do this multiple times looking for multiple strings? Here is what I have so far:
$data = explode('\pard',$rtf);
foreach ($data as $item) {
$values = preg_split('/[\t]/', $item);
if (in_array('shipped yesterday', $values)){
$key = array_search('shipped yesterday', $values);
print $values[$key + 1];
}else{
print_r($values);
}
}
The RTF file looks like the following:
booked in yesterday 50 41 78
packaged yesterday 62 45 48
shipped yesterday 46 52 62
So my code above is looking for 'shipped yesterday' then getting the first value next to it, in this case 46.
What's the most efficient way to do it for the rest of the values 'booked in yesterday' and 'packaged yesterday'?