1
Guys I have the following code:
<?php
$string = $_POST['search'];
foreach($results['results']['collection1'] as $collection) {
if(stristr($collection['prod']['text'],$string) !== false) {
echo "<div class='col-lg-4 col-sm-6'><img src='" . $collection['img']['src'] . "'><br />";
echo "<a target='_blank' href='" . $collection['prod']['href'] . "'>" . $collection['prod']['text'] . "</a><br />". $collection['valor'] . "</div>";
} else {
echo "Nada encontrado";
}
}
The problem that when the Else echo goes into action the result is this:
Nada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada encontradoNada....
The ideal is to appear only once the Nada encontrado
.
Try to put
;
after the last}
, and put abreak
after each return (fromif
and ofelse
)... In the case ofelse
stayselse { echo "Nada encontrado"; break; }
– gustavox
You can put an example of what you would have
$results['results']['collection1']
?– user3603