Jump to content

Convert Php Array To Jquery Array


Recommended Posts

You mean a Javascript array? jQuery is just a Javascript library.Just print out all the elements in a Javascript syntax.

echo 'var arr = [';$comma = false;foreach($arr as $item) {   // Make sure we don't add a comma before the first item of the JSON syntax array.  if($comma) {    echo ',';    $comma = true;  } echo " '{$item}' ";}echo ']';

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...