i have a php array like,
$array = array(1,2,3);
i know i can set variable by
var x = <?php echo $array; ?>
but problem starts from here, that "1" (in above line, $array[ 1 ] wouldn't be always one it may be, 0,1,2.. anything. So how can i do it?
Thanks in advance!
var x = JSON.parse('<?php echo json_encode($array); ?>');
"I have no special talent. I am only passionately curious." — Albert Einstein
Yeah, thanks for answer! However i found it someday ago.. and i am using it. But it is like
and after it i have x, x according to $array, $array.
var x = <?php echo json_encode($array) ?>
Do i need to use json.parse()?
And is there any other answer for Q.1?
EDIT: P.S. loved your signature shane.carr
Last edited by deepode; 03-27-2013 at 07:20 AM.
Reason: Comment about signature!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread