javascript - PHP Key Multiple Values to JSON -
i have array has key, , value array values; key word, , values synonyms; this
$arr = array(); $syns = ['hi','wassip','yeaboy','heya','heo']; $arr["hello"] = $syns; foreach($arr $key=>$value){ foreach($value $word){ echo $key." ".$word."\n"; } }
this disply each word, , each synonym word.
can converted json format? trying pass 1 page another, either through javascript, php, or however. how can pass array of synonyms each word?
simply use json_encode
example
$syns = ['hi','wassip','yeaboy','heya','heo']; $arr["hello"] = $syns; $jsonformat = json_encode($arr);
Comments
Post a Comment