cgm225 Posted May 25, 2008 Share Posted May 25, 2008 If I have an array with several entries, how can I echo/print only the third one? Quote Link to comment https://forums.phpfreaks.com/topic/107192-solved-only-printecho-third-value-in-array/ Share on other sites More sharing options...
.josh Posted May 25, 2008 Share Posted May 25, 2008 echo blah[2]; (it starts at 0) Quote Link to comment https://forums.phpfreaks.com/topic/107192-solved-only-printecho-third-value-in-array/#findComment-549567 Share on other sites More sharing options...
cgm225 Posted May 25, 2008 Author Share Posted May 25, 2008 What if the key values are not 1, 2, 3, 4 but rather 1000, 1001, 1002, or something else, how can I echo/print the third position regardless of the key name? Quote Link to comment https://forums.phpfreaks.com/topic/107192-solved-only-printecho-third-value-in-array/#findComment-549576 Share on other sites More sharing options...
Barand Posted May 25, 2008 Share Posted May 25, 2008 <? $a = array ('one' => 'aaa', 'two' => 'bbb', 'printMe' => 'ccc', 'four' => 'ddd'); $b = array_values($a); echo $b[2]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/107192-solved-only-printecho-third-value-in-array/#findComment-549580 Share on other sites More sharing options...
cgm225 Posted May 25, 2008 Author Share Posted May 25, 2008 perfect thank you Quote Link to comment https://forums.phpfreaks.com/topic/107192-solved-only-printecho-third-value-in-array/#findComment-549582 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.