Bird
0
0

Which PHP function converts a PHP array into a JSON formatted string?

easy📝 Conceptual Q2 of 15
PHP - File Handling
Which PHP function converts a PHP array into a JSON formatted string?
Ajson_decode()
Bjson_encode()
Cjson_parse()
Djson_stringify()
Step-by-Step Solution
Solution:
  1. Step 1: Identify function for encoding

    The function json_encode() converts PHP arrays or objects into JSON strings.
  2. Step 2: Eliminate incorrect options

    json_decode() does the opposite, and the others are not valid PHP functions.
  3. Final Answer:

    json_encode() -> Option B
  4. Quick Check:

    PHP array to JSON = json_encode [OK]
Quick Trick: Use json_encode to convert PHP data to JSON string [OK]
Common Mistakes:
  • Mixing up json_encode and json_decode
  • Using non-existent functions like json_parse

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes