unemployment Posted April 9, 2011 Share Posted April 9, 2011 How can I echo the array value? Here is the pre... Array ( [0] => Array ( [count] => 2 ) ) Here is my currrent code... <span class="blue"><?php echo $count; ?></span> Can I do this without using a foreach loop? Quote Link to comment https://forums.phpfreaks.com/topic/233167-echo-array-value/ Share on other sites More sharing options...
.josh Posted April 9, 2011 Share Posted April 9, 2011 what is the actual name of the array you are using (what you pre'd)? You would be using something like this: <span class="blue"><?php $array[0]['count']; ?></span> except replacing $array with the name of your array. Quote Link to comment https://forums.phpfreaks.com/topic/233167-echo-array-value/#findComment-1199242 Share on other sites More sharing options...
ted_chou12 Posted April 9, 2011 Share Posted April 9, 2011 one dimension array: $array = array("t", "r", "s"); echo $array[0]; foreach ($array as $a) {echo $a;} array with keys $array = array("t" => "1", "r" => "2", "s" => "3"); echo $array[t];//1 foreach ($array as $key => $val) {echo "Key is $key, Val is $val";} two dimensional array: $array = array(array("it", "is"), array("starting", "to"), array("get", "complicated")); echo $array[0][0];//it foreach ($array as $a) {echo $a[1];//is, to, complicated foreach ($a as $b) {echo $b;}//gives u all output } Ted Quote Link to comment https://forums.phpfreaks.com/topic/233167-echo-array-value/#findComment-1199253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.