I have a multidimensional array with associative values... I want to add some information to multiple arrays at the same time. Doing $array1=$array2=array(...
seems to work but I'm worried that it's too easy. Will any array get extra data or have data overwritten by doing this?
What kind of unexpected behavior might I expect from this kind of code? Al should have 3 entries in it, while Bob and Chris will each have two... right? It seems to work, but I'm worried I'm overlooking something.
<? $content['Al'][]= array(
"link"=>"/admin.php",
"text"=>"Admin Login",
"icon"=>"wp.png");
$content['Al'][]=$content['Bob'][]=$content['Chris'][] = array(
"link"=>"/Wordpress/wp-login.php",
"text"=>"Login to Wordpress",
"icon"=>"wp.png");
$content['Al'][]=$content['Bob'][]=$content['Chris'][] = array(
"link"=>"/Gallery/Login.php",
"text"=>"Login to Gallery",
"icon"=>"picutres.jpg");
function userbox($heading,$contents){
if($contents=="") return;
echo "<div class=\"refbox\">
<h2>".$heading."</h2>
<p>";
foreach ($contents as $key){
if($key['link']!="")echo "<a href=\"".$key['link']."\">";
if($key['icon']!="")echo"<img src=\"/images/icons/".$key['icon']."\" alt=\"".$key['text']."\" class=\"icons\">";
echo $key['text'];
if($key['link']!="")echo "</a>";
if($key['updated']!="")echo " <span style=\"float:right;\">(".$key['updated'][0].")</span>";
echo "<br>";
}
echo "</p>
</div>";
}
?>
Then in the content of the page I have
<?userbox($user,$content[$user]);?>
This should show a 'refbox' div
with the users links in it within the page.