Fabrizio Bartolomucci Fabrizio Bartolomucci - 3 months ago 8
JSON Question

JsonEncode returns empty string in php

I am trying to encode an Array into Json. I tried with a complex one and the result was empty. So I tried with a very simple array and the result was the same:

$result=Array("pippo", "pluto");
print_r($result);
json_encode($result);


The print_r correctly prints the array, but json_encode returns nothing.
What may be the problem?

Answer

Please try below

<?php
    $result=Array("pippo", "pluto");
    print_r($result);
    echo json_encode($result);
?>

Or Refer URL https://eval.in/631616

Comments