PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat May 30, 2020 11:10 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Jan 19, 2010 6:12 am 
Offline
Forum Commoner

Joined: Tue Jun 23, 2009 3:51 am
Posts: 54
Can any body tell me simple two lines code for converting PHP array to javascript array.
$arr=array("a","b","c");
I have to pass array as argument like onclick="myFunction('<? echo $arr;?>')".

<script language="javascript">
function myFunction(jsArray)
{
I want to show "a","b","c" here.
}
</script>

Can any body tell me how should i do?


Top
 Profile  
 
PostPosted: Tue Jan 19, 2010 9:53 am 
Offline
DevNet Master
User avatar

Joined: Mon Feb 24, 2003 11:12 am
Posts: 2572
Location: The Republic of Texas
json_encode()

_________________
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.


Top
 Profile  
 
PostPosted: Tue Jan 19, 2010 11:52 pm 
Offline
Forum Commoner

Joined: Tue Jun 23, 2009 3:51 am
Posts: 54
I didnt find any thing there to convert PHP array to javascript array there.


Top
 Profile  
 
PostPosted: Wed Jan 20, 2010 8:50 am 
Offline
DevNet Master
User avatar

Joined: Mon Feb 24, 2003 11:12 am
Posts: 2572
Location: The Republic of Texas
Well, that's exactly what it's for.

_________________
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.


Top
 Profile  
 
PostPosted: Thu Jan 28, 2010 7:46 am 
Offline
Forum Newbie

Joined: Wed Jan 27, 2010 5:22 am
Posts: 9
Location: Bangalore


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group