I need to create data as this:
{v: 1.0, f: '<h1>1.0</h1>'}
...
but now I only know how to get first parametr so I get: {v: 1.0}
,
with this code:
$temp[] = array('v' => (string) $naziv);
what I need to add to my code: $temp[] = array('v' => (string) $naziv);
to get like this json: {v: 1.0, f: '<h1>1.0</h1>'}
$naziv = 1.0;
$header ='<h1>1.0</h1>';
$temp[] = array('v' => (string) $naziv,
'f' => (string) $header
);
echo json_encode($temp);
or
$naziv = 1.0;
$header ='<h1>1.0</h1>';
$temp['v'] = $naziv;
$temp['f'] = $header;
echo json_encode($temp);
<?php
$naziv = 1.0;
$temp = array(
"v" => $naziv
"f" => "<h1>{$naziv}</h1>",
);
echo json_encode($temp);
This will result in
{"v":1.0,"f":"<h1>1.0</h1>"}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.