Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript to php syntax changes?

    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?

    Code:
    for (var i=0; i<originalval.length; i++){
    	newval[newval.length]=originalval.charCodeAt(i)
            newval="["+newval.join(",")+"]"
    }

  • #2
    Regular Coder
    Join Date
    Oct 2008
    Posts
    214
    Thanks
    5
    Thanked 22 Times in 22 Posts
    As for the for structure use:

    PHP Code:
    //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?
    Last edited by AlexV; 10-16-2009 at 08:54 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •