How do I put a json generated by php into 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
How do I put a json generated by php into 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
As you want, you should use the htmlentities()
function so that the double quotation marks are converted to your HTML entity :
$array = array('a','b','c');
$json = json_encode($array);
$link = '<a href.. tag="'.htmlentities($json).'">';
See example on Ideone .