clown99 Posted March 12, 2009 Share Posted March 12, 2009 Evening all, hoping one of you could help me with a little problem i'm having, (very new to PHP you see). Basically, I need to display the results from an array that is automatically created. Easy enough. But the problem I'm having is that the array will be changing in size, so how do I get it to only display rows with contents in them? At the moment I've go this. But it only displays 10 rows. If the array shrinks, it errors on the empty ones and if it grows it'll miss some. Obviously I can increase it but then it displays all the empty ones, (before I knew this I set it to infinity, wow, had displayed error messages for 120,000 rows before I managed to stop it!! ) Any help appreciated for ($row = 0; $row < 10 ; $row++) { echo "<li>".$matches[$row][1]."</li>"; } Link to comment https://forums.phpfreaks.com/topic/149187-solved-row-and-array-help/ Share on other sites More sharing options...
The Little Guy Posted March 13, 2009 Share Posted March 13, 2009 do this foreach($row as $value){ echo "<li>".$value."</li>"; } Link to comment https://forums.phpfreaks.com/topic/149187-solved-row-and-array-help/#findComment-783425 Share on other sites More sharing options...
samshel Posted March 13, 2009 Share Posted March 13, 2009 or this $cnt = count($matches); for ($row = 0; $row < $cnt ; $row++) { echo "<li>".$matches[$row][1]."</li>"; } Link to comment https://forums.phpfreaks.com/topic/149187-solved-row-and-array-help/#findComment-783439 Share on other sites More sharing options...
clown99 Posted March 13, 2009 Author Share Posted March 13, 2009 Wow thankyou both very much. Works brilliantly Problem solved Link to comment https://forums.phpfreaks.com/topic/149187-solved-row-and-array-help/#findComment-783449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.