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? 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) 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? 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]; ?> 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 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
Archived
This topic is now archived and is closed to further replies.