Dysan Posted November 21, 2007 Share Posted November 21, 2007 How do I display all the items within an array? Also, how do I delete a particular item from an array? Link to comment https://forums.phpfreaks.com/topic/78312-display-all-array-items/ Share on other sites More sharing options...
boushley Posted November 21, 2007 Share Posted November 21, 2007 print_r($myArray); Link to comment https://forums.phpfreaks.com/topic/78312-display-all-array-items/#findComment-396250 Share on other sites More sharing options...
Dysan Posted November 21, 2007 Author Share Posted November 21, 2007 No. How do I actually display each item as a item, not as a array. eg, if the array contains 10,4,5,2,7,6,9 then the following should be display on the screen: 10452769 Link to comment https://forums.phpfreaks.com/topic/78312-display-all-array-items/#findComment-396256 Share on other sites More sharing options...
premiso Posted November 21, 2007 Share Posted November 21, 2007 www.php.net/foreach <?php foreach ($myArray as $val) { echo $val; } ?> Link to comment https://forums.phpfreaks.com/topic/78312-display-all-array-items/#findComment-396268 Share on other sites More sharing options...
thebadbad Posted November 21, 2007 Share Posted November 21, 2007 Use unset() to "destroy an single element of an array". <?php $array = array('a', 'b', 'c'); unset($array[0]); //$array is now array('b', 'c'); ?> Link to comment https://forums.phpfreaks.com/topic/78312-display-all-array-items/#findComment-396285 Share on other sites More sharing options...
boushley Posted November 23, 2007 Share Posted November 23, 2007 As well, for printing... you could do this <?php echo implode('', $myArray); ?> Not sure on the efficiency of one or the other. Link to comment https://forums.phpfreaks.com/topic/78312-display-all-array-items/#findComment-397583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.