Skip to content

Instantly share code, notes, and snippets.

@aquelito
Created February 20, 2014 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aquelito/00b3f0b7045652313368 to your computer and use it in GitHub Desktop.
Save aquelito/00b3f0b7045652313368 to your computer and use it in GitHub Desktop.
Encodage du tableau JSON passer via data attribute
<?php
// UPDATE::AxelRoche
$var_modal = array(
'id' => $_product->getId(),
'title' => $_product->getName(),
'price' => $_product->getPrice(),
'image' => $_product->getImageUrl(),
'qty' => 1,
);
$jsonModalProduct = htmlspecialchars(json_encode($var_modal), ENT_QUOTES, 'UTF-8');
?>
<button data-modal-product="<?php echo $jsonModalProduct; ?>">My button</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment