Bring all results out of the foreach

Asked

Viewed 49 times

-1

I’m not managing to bring all the results out of the foreach. Follow the code:

 foreach ($_POST['filtroOpt'] as $key=> $value){

          $filtro = "AND ".$value." LIKE '%".$_POST['term'][$key]."%' ";
          echo $filtro."</br>";
}

The echo inside the foreach displays all the results I want, but when I try to put it out it displays only the first result. I tried some things like for example the array but did not succeed.

Thank you in advance.

1 answer

0

The obstacle was healed with the implode as in the example below:

foreach ($_POST['filtroOpt'] as $key=> $value){
 $filtro[] = "AND ".$value." LIKE '%".$_POST['term'][$key]."%' ";
//echo $filtro;
$Output = implode("", $filtro);
}

Called the $Output out of the foreach worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.