php - How can I store string from object as a variable? -


i object in echo $output:

{   "key":"a-string-with-letters-and-numbers" } 

how can store string ("a-string-with-letters-and-numbers") variable, or can echo directly selectors?

i need store string script:

options({   key: "<?php echo $output ?>" }); 

your object not object in php, json string need decode convert in php object or array

 $json  = '{"key":"a-string-with-letters-and-numbers"}';  $object = json_decode($json);  echo $object->key; // object   $array = json_decode($json, true);  echo $array['key']; // array 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -