Looping through an array

I have an array

echo '<pre>';print_r($assetArray);echo '</pre>';

resulting in

Array
(
    [monitor] => Array
        (
            [0] => Array
                (
                    [asset_id] => 404
                    [0] => 404
                    [name] => ryuiyui yui
                    [1] => ryuiyui yui
                    [monitor_id] => 1
                    [2] => 1
                    [beginning_ru] => 20.0
                    [3] => 20.0
                    [ending_ru] => 33.0
                    [4] => 33.0
                )

        )

)

I’m trying to loop through it like

if(!array_key_exists('monitor',$assetArray)) { 

	foreach($assetArray['monitor'] as $value) {

					
	  echo "<tr>";
	  echo "\r\n";
	  echo "<td>";
	  echo "\r\n";
	  echo '<a class="nav-link jqeasytooltip" href="../monitors/show_monitor.php?id='.$value['monitor_id'].'" data-tiptheme="tipthemewhite" data-tipcontent="Monitor">';
	  echo "\r\n";
	  echo $value['name'];
	  echo "\r\n";
	  echo "</a>";
	  echo "\r\n";
	  echo "<td>";
	  echo "\r\n";
	  echo '<a class="nav-link jqeasytooltip" href="../monitors/show_monitor.php?id='.$value['monitor_id'].'" data-tiptheme="tipthemewhite" data-tipcontent="Monitor">';
	  echo "\r\n";
	  echo $value['beginning_ru'].' = '.$value['ending_ru'];
	  echo "\r\n";
	  echo "</a>";
	  echo "\r\n";
	  echo "</tr>";
	  echo "\r\n";					  

	}	
}

but it produces nothing…
Do I have the correct syntax?

What’s wrong with this line?

4 Likes

I would suggest, lurt, that you invest in a rubber duck. Not the first time this has tripped you up :wink:

4 Likes

I agree. Examine what the line does.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.