I made this code :
$matches = array();
preg_match_all('/"Type":".+?",/', $text, $matches);
foreach($matches[0] as $match) {
if (isset($_GET['dvd']) && !empty($_GET['dvd'])) {
$dvd = $_GET['dvd'];
if (stripos($match, 'DVD') !== false) {
$match = '';
}
}
echo $match;
}
In this code i search for the word "type" in $text and it stores the whole line with the words ahead of it in the array. And then i loop through each one and see if the word DVD is there. If it is then, it removes it and displays a blank line.
Now I also want to search for suppose manufacturer and display it beneath every type returned.
So it should return suppose the result :
Type: HDD
Manufacturer: WD
Type: Flash Drive
Manufacturer: Transcend
Type: CD
Manufacturer: Sony
So I tried it with putting another preg_match_all expression:
$anotherMatch = array();
preg_match_all('/"Manufacturer":".+?",/', $text, $anotherMatch);
And I tried combining this with the previous foreach expression with an && operator but it didn't work. Also I tried different foreach expressions and then one for echoing at the end. but that also didn't work.
Can you tell me how to achieve the desired result. Thanks...