Billy's Blog

To post pictures and other goodies for free on the net.

My Photo
Name:
Location: Utah, United States

Born in Kapiolani Children's Medical Center, just a few blocks from Waikiki. Graduated from Kahuku High School. Rode BMX Freestyle for most of my life (more than 20 years), now my 8 year old son is ripping up the skate parks, but plans on getting drafted by the SeaHawks as a WR.

Sunday, February 26, 2012

And PHP Arrays[ ] ?!?

inside of your JavaScript section, insert a <?php?> snippet


<script type="text/javascript">

var phpName = new Array();
var phpDesc = new Array();

<?php
foreach($imgName as $key => $value)
{
echo "phpName[$key] = $value;\n"; //number
}
foreach($imgDesc as $key => $value)
{
echo "phpDesc[$key] = \"$value\";\n"; //string
}
?>
</script>

make sure to escape your double quotes!
This will print out the javascript with each iteration explicitly assigned, but it works! (no json or anything needed)

0 Comments:

Post a Comment

<< Home