2
How do I place a json generated by php in a link tag
$array = array('a','b','c');
$json = json_encode($array);
$link = '<a href.. tag="'.$json.'">';
// tried with JSON_HEX_QUOT | JSON_HEX_TAG and does not work
2
How do I place a json generated by php in a link tag
$array = array('a','b','c');
$json = json_encode($array);
$link = '<a href.. tag="'.$json.'">';
// tried with JSON_HEX_QUOT | JSON_HEX_TAG and does not work
2
In the form you intend, you must make use of the function htmlentities()
so that double quotes are converted to your HTML entity:
$array = array('a','b','c');
$json = json_encode($array);
$link = '<a href.. tag="'.htmlentities($json).'">';
See example in Ideone.
Browser other questions tagged php json
You are not signed in. Login or sign up in order to post.
yes, punch it breaks with double quotes generated by json_encode
– raddx