Convert JSONL to Array with PHP



The json_decode function can be used as shown below −

json_decode($json_string_that_needs_to_be_converted, true);

The below lines of code can be used to convert JSONL to array format −

$json_string = '["[email protected]","[email protected]","[email protected]"]';
$array_of_data=json_decode($json_string);

An alternate is to use the below code, wherein the way json_string has been defined changes −

Example

$json_string = "[\"[email protected]\",\"[email protected]\",\"[email protected]\"]";
$array_of_data=json_decode($json_string);

Output

This will produce the following output −

Array("[email protected]","[email protected]","[email protected]")
Updated on: 2020-04-06T08:31:12+05:30

397 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements