iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-09-2004, 09:06 AM
WebProWorld Pro
 
Join Date: Feb 2004
Location: England Baby!
Posts: 216
icb01co2 RepRank 0
Default Javascript and php

Hello there.

I have set a javascript array a[], each array element holds a list of training centres i.e.

a[0] = leeds-edinburgh-leeds-leeds.

i want to split these centres into javascript variuables i.e.

echo "<script>
var aims_array = a[$i].split("-");
</script>
";

but for some unknown reaseon when i add this code to my .php script i get random 0's printed to the screen
i.e.

00000000000000000000
00000000
000000000000000
00
0000000000000
000000

i'm not printing anything to the screen so why should this happen?

Thanks, Chris.
Reply With Quote
  #2 (permalink)  
Old 08-09-2004, 11:25 AM
Easywebdev's Avatar
WebProWorld Veteran
 
Join Date: Apr 2004
Posts: 310
Easywebdev RepRank 1
Default

echo "<script>
var aims_array = a[$i].split("-");
</script>
";

Your problem is the use of double quotes in the echo statement as it encounters another set inside the holding quotes.

Either escape the inner quotes ala split(\"-\"); or use single quotes around the echo ala
echo '<script> var aims_array = a[$i].split("-"); </script>';

Some things to be aware of using ' and " in php.
Everything inside " " (double quotes) is parsed - echo " $some_variable " will output the value of $some_variable.

Nothing inside ' ' (single quotes) is parsed - echo ' $some_variable ' will do just that, print the text $some_variable.

Hope that helps.
__________________
"I have not failed. I have found 10,000 ways that don't work" - Thomas Edison.
"The secret to creativity is knowing how to hide your sources" - Albert Einstein.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:55 AM.



Search Engine Optimization by vBSEO 3.3.0