Remove quote from an array in json (Php)
I tryed to remove the quote from my json output, but nothing work...
1 => array(
'y' => str_replace('"','',$behaviour[5]['wcount']),
'name' => 'Slice Name B'
),
Output
{"y":"3","name":"Slice Name B"}
I need to remove the string "3"
I tryed str_replace('"','',$behaviour[5]['wcount'])
and str_replace("'","",$beha开发者_JAVA技巧viour[5]['wcount']);
Someone can help me please ?
Try this instead:
1 => array(
'y' => intval($behaviour[5]['wcount']),
'name' => 'Slice Name B'
),
If you're running PHP 5.3.3. or better, you can pass JSON_NUMERIC_CHECK
to json_encode
which should do what you want:
$encoded = json_encode($data, JSON_NUMERIC_CHECK);
精彩评论