multiple assigning array in foreach?

Okay now we see what you want!! but it wont work like this. The best way would be to create a class for that -> http://php.net/manual/en/language.oop5.basic.php. But here a basic solution which can work:

$messages = array();
$message = array();
$message['from'] = "john";
$message['to'] = "phil";
$message['lastdata'] = "john@okay";

array_push($messages, $message);

Do this for every message or whatever it is and then this:

foreach ($messages as $message){
  if (strpos($message,"okay") !== false){
      echo "<tr>";
      echo "<td>".$message['from']."</td>";
      echo "<td>".$message['to']."</td>";
      echo "<td>".$message['lastdata']."</td>";
      echo "</tr>";  
   }
}

Leave a Comment