Dysan Posted November 23, 2007 Share Posted November 23, 2007 To display an arrays contents, I have been using print_r(), but this displays the array across the page/screen. Is there a function that displays the array vertically? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted November 23, 2007 Share Posted November 23, 2007 use the HTML tag's on either side of it like this: <pre> <?php // Grab Array Here ?> </pre> Regards ACE Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted November 23, 2007 Share Posted November 23, 2007 Iterate the array, not using print_r, but using a while or foreach loop. foreach($arrayname as $arrayvalue) { echo $arrayvalue."<br />\n"; } That would work too, and would get rid of the pesky tacky Array() onthe top and bottom. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 24, 2007 Share Posted November 24, 2007 Iterate the array, not using print_r, but using a while or foreach loop. foreach($arrayname as $arrayvalue) { echo $arrayvalue."<br />\n"; } That would work too, and would get rid of the pesky tacky Array() onthe top and bottom. using your code is a waste of time .. if you want to view the content of array and how it is formated there is no better way than var dump and print_r echo '<pre>'; print_r(); echo '</pre>'; Quote Link to comment Share on other sites More sharing options...
dbo Posted November 24, 2007 Share Posted November 24, 2007 using your code is a waste of time .. Classy response. It's hardly a "waste of time." It really depends on the context. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted November 24, 2007 Share Posted November 24, 2007 That's true, if you have information that you need to iterate through and order nicely, then my way is better, yourway is the basics of basic, but I suppose it gets the job done. 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.