Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2009, 07:41 PM   PM User | #1
Limekiller
New to the CF scene

 
Join Date: Oct 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Limekiller is an unknown quantity at this point
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(",")+"]"
}
Limekiller is offline   Reply With Quote
Old 10-16-2009, 08:50 PM   PM User | #2
AlexV
Regular Coder

 
AlexV's Avatar
 
Join Date: Oct 2008
Location: Near Montreal, Quebec - Canada.
Posts: 214
Thanks: 5
Thanked 22 Times in 22 Posts
AlexV is an unknown quantity at this point
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..
AlexV is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:17 AM.


Advertisement
Log in to turn off these ads.