See this:
$q = 'blah';
for($k = 0; $k < count($results_array); $k++){
$results_array_ . $k = explode(',', $results_array[$k]);
foreach($results_array_ . $k as $key => $value){
if (stripos($value, $q) === false) {
unset($results_array_ . $k[$key]);
break;
}
}
}
On line 3 I'm simply using "$results_array_ . $k" and it's working just fine, but on line 6 I'm getting PHP parse errors on "unset($results_array_ . $k[$key])", why is this happening?
I appreciate anykind of help
Why I'm doing it:
I have an array named results_array:
var_dump($results_array):
0 => php,mysql,jquery,ruby,html,css,lamp
1 => mouse,keyboard,laptop,pad
2 => table,sofa,caption
and I have a $q which stands for query, I want to search in the $results_array and remove the items which has nothing to do with the query, so if I set $q=a then results array should be this:
0 => lamp
1 => keyboard,laptop,pad
3 => table,sofa,caption
now, I want to put the above results in each index of the results_array, at the end results_array should be:
0 => lamp
1 => keyboard
2 => laptop
3 => pad
4 => table
5 => sofa
6 => caption