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? Quote Link to comment Share on other sites More sharing options...
boushley Posted November 21, 2007 Share Posted November 21, 2007 print_r($myArray); Quote Link to comment 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 Quote Link to comment 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; } ?> Quote Link to comment 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'); ?> Quote Link to comment 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. Quote Link to comment 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.