Languages :: PHP :: Arrays in PHP |
|||
| By: PHP newbee |
Date: 19/06/2003 00:00:00 |
Points: 20 | Status: Answered Quality : Excellent |
|
Thanx for the previos help, all of your for newline question. I have a question regarding arrays can i add elements to an array like array[]; i=0;//at start some loop { array=$string i++; } The content of the variable $string keeps on changing and i want to store the values of that variable sequentially. |
|||
| By: keynine | Date: 19/06/2003 20:13:00 | Type : Comment |
|
| it is better in this way: some loop { array[] = $string; } the array variable will expand its array size in every loop with its index incrimented. |
|||
| By: VGR | Date: 19/06/2003 20:44:00 | Type : Answer |
|
| no, it's not "better", it's different. And it's not very practical if you need to add other data in the same array element and you can't affect it to array(the values) ;-) In that case, you need the index. By the way, both produce exactly the same array finally, so... yes, that's good : $thearray=array(); // emptied $i=0;//at start some loop { $thearray[$i]=$string; $i++; } // loop |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








