Foreach Loop PHP

Foreach Loop PHP

The Sample Code will use the Forceach loop to print out the associative array in the browser

<?php

$model=array(
       
	        "Model T" => "0000",
		"Model U" => "1111",
		"Model V"=> "2222"


         );

    .// $th3Model Reference to the associative Array Key  for example "Model T"  
     // while $theSerial Reference to the value of the associative Array  for example  " 0000 "
	foreach($model as $theModel => $theSerial){
		
		
		echo $theModel.'<br>';
		echo $theSerial.'<br>';
		
		
		
	}

?>





The Result

Model T
0000
Model U
1111
Model V
2222



Leave a Comment

eleven − 5 =