PHP Arrays

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
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

PHP Arrays

Post by james3302 »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


I have code that looks like this

Code: Select all

 
$wc202Array = array(
//in here I have around 150 entries
);
 
$sql = '';
foreach($wc202Array as $wc)
{
   $sql .= "In here I have a select statment and unions the others as it loops through";
}
 
$sql = substr($sql, 0, -6);  //get rid of last "union"
$stmt = OCIParse($connection, $sql); 
OCIExecute($stmt); 
 
How many entries can I have in my array? I have heard that it depends on the menory_limit in the PHP.ini file. Is there any faster way to do this code?


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
BomBas
Forum Commoner
Posts: 41
Joined: Wed Mar 04, 2009 1:04 pm

Re: PHP Arrays

Post by BomBas »

Maybe this code can be more effective, it depends on what you want to do.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP Arrays

Post by pickle »

Technically I guess there would be a limit, but it's extraordinarily high. The default memory limit is 8MB. Have you ever looked at an 8MB text file? There's tons of stuff in there. For the vast majority of practical applications, the size of arrays can be considered infinite.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: PHP Arrays

Post by kaisellgren »

pickle wrote:Technically I guess there would be a limit
No guessing. There is a limit, but very rarely it is a practical limit.
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

Re: PHP Arrays

Post by james3302 »

The sql statment totals then length of a cable, or sums the number of records depends on what it's conuting. Then it displays it inside a table. Some php pages have about 10 different sql statements with loops.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHP Arrays

Post by Benjamin »

Well you are not even remotely close to hitting any sort of limit.
Post Reply