OK, i'm sure this is a really easy one... what does it mean when i call my array and it just prints 'Array' ?
to print the array you use echo print_r($arrayname); to printing apart of the array echo $arrayname[0]
that's just the way i do it because i found it on the net but if just print_r works thanks for telling me.
Yes, say you have an array: <?php $fruit = array(apple,banana,pear); ?> PHP: There are multiple ways I can output that: <?php //1. echo $fruit; //Returns "Array" //2. print_r($fruit); // Returns "Array ( [0] => apple [1] => banana [2] => pear )" //3. echo $fruit[0]; //Returns "apple"; echo $fruit[1]; //Returns "banana"; echo $fruit[2]; //Returns "pear"; //4. foreach($fruit as $fruity){ echo "$fruity,"; } //Returns "apple,banana,pear," ?> PHP:
Try not to use variables within double quotes if you can avoid it, much slower than just doing echo $fruity , ',';. (Not going to mention while loops here, that belongs in a different place.) Dan
I have never bothered with those really small things to save a few milliseconds, unless optimization is requested by the client for whatever reason. The sites I have made that are big enough to notice it, have servers that are more than capable of handling it. And I prefer it be easier/lessconfusing to edit for other coders
printf will be trend with php 5 example : $name = "xfreex"; printf("%s",$name"); %s is string name %d is double %i is integer %b is boolean