Length of array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jolinar
Forum Commoner
Posts: 61
Joined: Tue May 24, 2005 4:24 pm
Location: in front of computer

Length of array

Post by jolinar »

I was wondering how you check the length of an array, either that or the posibility of using somthing that will stop looping when an array ends?
User avatar
jolinar
Forum Commoner
Posts: 61
Joined: Tue May 24, 2005 4:24 pm
Location: in front of computer

Post by jolinar »

Sorry, I'm a muppet. Just found a solution.

Code: Select all

$category_ID = $connector->query_column("SELECT category_ID FROM gallery_category");
 $category_name = $connector->query_column("SELECT category_name FROM gallery_category");
 $category_description = $connector->query_column("SELECT category_description FROM gallery_category");
 $category_URL = $connector->query_column("SELECT category_URL FROM gallery_category"); 
 $preview = $connector->query_column("SELECT category_preview FROM gallery_category");
	
 $i = 0;
 $n = sizeof($category_name);
	
 echo "<table border='1'>";
 for($i=0; $i<$n; $i++)
 {
sizeof seems to do the job fine
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

yup sizeof() will work as will count()
Post Reply