mkosmosports Posted January 12, 2007 Share Posted January 12, 2007 I have a multidimensional array..$monthss = array("2digit"=>array("01","02","03","04","05","06","07","08","09","10","11","12",),"shorttxt"=>array("Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"), "longtxt"=>array("January","February","March","April","May","June","July","August","September","October","November","December"));Then I run a loop and I want to take out values from that array and place them as a variable. Ive got:$var = $monthss[$2digit($trmon)]; as well as several other varieties...Obviously this is not the way to use the md array.... :P Any help appreciated..Thanks. Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/ Share on other sites More sharing options...
scotmcc Posted January 12, 2007 Share Posted January 12, 2007 Try this:<?php $a[1][1] = "one one</br>"; $a[1][2] = "one two</br>"; $a[2][1] = "two one</br>"; $a[2][2] = "two two</br>"; echo $a[1][1]; echo $a[2][1];?> Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/#findComment-158877 Share on other sites More sharing options...
Jessica Posted January 12, 2007 Share Posted January 12, 2007 use [] not () Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/#findComment-158878 Share on other sites More sharing options...
mkosmosports Posted January 12, 2007 Author Share Posted January 12, 2007 Is there a way I can manually assign ID keys in a multidimensional array? Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/#findComment-158894 Share on other sites More sharing options...
scotmcc Posted January 12, 2007 Share Posted January 12, 2007 <?php $months["foo"]["bar"] = "foobar"; echo $months["foo"]["bar"]; ?> Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/#findComment-158897 Share on other sites More sharing options...
Jessica Posted January 12, 2007 Share Posted January 12, 2007 The same way you do for a regular array:[code]$arr = array("one"=> array("smaller"=>1, "bigger"=>2), "two"=>array("etc"=>2));[/code](ps: I didn't test that) Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/#findComment-158901 Share on other sites More sharing options...
mkosmosports Posted January 12, 2007 Author Share Posted January 12, 2007 Thanks scotmcc and Jesirose for your help! Im gonna use that and put together what I want to achieve. Hopefully it'll work. Ill let ya'll know.... Link to comment https://forums.phpfreaks.com/topic/33855-just-cant-seem-to-get-this-syntax-right/#findComment-158906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.