Friday, July 31, 2009

How do I show spaces in my printed results for php?

I am trying to print out a sentence using this php code:





%26lt;?


$myArray=array("The", "quick", "brown", "fox", "jumped",


"over", "the", "lazy", "dog");


$numElements=count($myArray);


for($counter=0; $counter%26lt;$numElements; $counter++)


{print ($myArray[$counter]); }


?%26gt;





When I check the results the words are pushed together without spaces how do I show spaces in my results?


Thanks

How do I show spaces in my printed results for php?
hi. for me i do not usually use a space i use a tab which can be inputted by the keys "\t" without the "" yups. hope that helps ((:
Reply:Another way to do this would be the implode function that converts the array to a string with a space or whatever you want separating the array values...





$myString = implode(' ',$myArray);


print $myString;
Reply:%26lt;?php


$myArray=array("The", "quick", "brown", "fox", "jumped",


"over", "the", "lazy", "dog");


$numElements=count($myArray);


for($counter=0; $counter%26lt;$numElements; $counter++)


{print ($myArray[$counter].' '); }


?%26gt;


No comments:

Post a Comment