Is json_encode php result NULL?

Possible duplicate:
json_encode returns NULL?

I am having a strange problem with json_encode()in php. Pretty simple code:

$content = json_encode(array('content1' => $arm_length,
                             'content2' => $body_length));
echo $content;

$arm_lengthand $body_lengthcontain HTML markup for the two drop-down menus. My problem is what echoshows NULLfor content1and content2. If I clean json_encode()and just do it print_r($content), it will display all the data as it should be.

Does anyone know what is going on here? Is there certain data that cannot be parsed in JSON? I have done this several times using Ajax / PHP and have never experienced any problems.

Cheers for any help with this.

+1
source share
2 answers

json_encode() () null , (= -UTF-8) .

, UTF-8, .

json_last_error() . ( PHP 5.3)

: json_encode()

+4

vars " : \" add_slashes ($ arm_length)

json \n ( ) , - http://json.org/ p >

0

All Articles