View Full Version : javascript to php syntax changes?

10-16-2009, 07:41 PM
Be gentle, because I'm trying to learn a few things here about working with php.

I have some javascript that I'm trying to transcode for php and obviously I don't know all the syntax variations because I keep breaking it. Can somebody show me how to convert this simple "for" loop to php syntax?

for (var i=0; i<originalval.length; i++){

10-16-2009, 08:50 PM
As for the for structure use:

//If $originalval is an array
for ($i = 0; $i < count($originalval); $i++)


//If $originalval is a string use strlen or mb_strlen if the string is Unicode
for ($i = 0; $i < strlen($originalval); $i++)


I'm not sure what does the loop do... Can you explain what you want to do?