{"id":3007,"date":"2012-05-03T17:33:11","date_gmt":"2012-05-03T15:33:11","guid":{"rendered":"http:\/\/www.beseit.net\/?p=3007"},"modified":"2013-02-10T18:28:35","modified_gmt":"2013-02-10T16:28:35","slug":"javascript-array-php-a-array-js","status":"publish","type":"post","link":"https:\/\/www.beseit.net\/?p=3007","title":{"rendered":"JavaScript: array php a array JS"},"content":{"rendered":"<p><iframe loading=\"lazy\" src=\"\/finestres_prog\/PHP\/form_php\/array_php_JS.php\" frameborder=\"0\" scrolling=\"yes\" width=\"600\" height=\"80\"><\/iframe>[sourcecode language=&#8217;php&#8217;]<br \/>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"><br \/>\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><\/p>\n<p><head><br \/>\n<!--\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\n--><br \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=iso-8859-1\"\/><\/p>\n<p><meta http-equiv=\"Content-Language\" content=\"ca\" \/><br \/>\n<title>passsar array php a JS<\/title><\/p>\n<p><?php $array = array('one', 'two', 'three'); ?><\/p>\n<p><script type=\"text\/javascript\">\nvar xx=new Array(\"<?=implode(\"\\\",\\\"\", $array); ?>\")\n<\/script><\/p>\n<p><script type=\"text\/javascript\">\nfunction f0(){\nalert(xx[0]);}\n<\/script><\/p>\n<p><script type=\"text\/javascript\">\nfunction f1(){\nalert(xx[1]);}\n<\/script><\/p>\n<p><script type=\"text\/javascript\">\nfunction f2(){\nalert(xx[2]);}\n<\/script><\/p>\n<p><\/head><br \/>\n<?php $array = array('one', 'two', 'three'); ?><\/p>\n<p><body><\/p>\n<p>Exemple com passar una variable array de php a javascrip<\/p>\n<p><!--<?php echo $array[1]; ?> --><\/p>\n<p><input name=\"B1\" type=\"button\" value=\"XX[0]\" onclick=\"f0()\" \/><br \/>\n<input name=\"B2\" type=\"button\" value=\"XX[1]\" onclick=\"f1()\" \/><br \/>\n<input name=\"B3\" type=\"button\" value=\"XX[2]\" onclick=\"f2()\" \/><\/p>\n<p><\/body><\/p>\n<p><\/html><\/p>\n<p>[\/sourcecode]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[sourcecode language=&#8217;php&#8217;] passsar array php a JS Exemple com passar una variable array de php a javascrip [\/sourcecode]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[],"class_list":["post-3007","post","type-post","status-publish","format-standard","hentry","category-javascript-sql"],"_links":{"self":[{"href":"https:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/3007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3007"}],"version-history":[{"count":8,"href":"https:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/3007\/revisions"}],"predecessor-version":[{"id":3736,"href":"https:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/3007\/revisions\/3736"}],"wp:attachment":[{"href":"https:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}