-9

Just wondering if it is possible to convert a PHP array to JSON string Heres the following PHP array:

array ( 
     'players' => array ( 
          '123' => '345'
          '567' => '789'
      ), 
     'non_players' => array ( 
          0 => '71558060', 
          1 => '14451395', 
          2 => '16428783', 
          3 => '12070702', 
          4 => '16872249', 
          5 => '10081837', 
          6 => '10000363', 
          7 => '10084478', 
     ), 
)

Is it possible to convert to JSON string?

4
  • did you check google.co.in/… Commented May 22, 2014 at 11:38
  • 3
    Yes there is, it is called json_encode() Commented May 22, 2014 at 11:38
  • 1
    Please don't think before posting to SO. :) Commented May 22, 2014 at 11:39
  • 1
    People should have more reputation to ask questions... it would eliminate a lot of these trivial and ill-researched questions. Commented May 22, 2014 at 11:43

1 Answer 1

0

You could just use json_encode(), from the PHP manual: http://www.php.net/manual/en/function.json-encode.php

2
  • Wont that just turn it into a JSON array? Commented May 22, 2014 at 11:46
  • JSON in PHP is just a String (special formatted string). So it will convert the PHP array into a valid JSON string. Commented May 22, 2014 at 11:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.