使用 PHP 將 JSONL 轉換為陣列


json_decode 函式可用如下所示 −

json_decode($json_string_that_needs_to_be_converted, true);

以下程式碼可用於將 JSONL 轉換為陣列格式 −

$json_string = '["m@gmail.com","p@gmail.com","q@gmail.com"]';
$array_of_data=json_decode($json_string);

另一種方法是使用以下程式碼,其中 json_string 的定義方法發生了變化 −

示例

$json_string = "[\"m@gmail.com\",\"p@gmail.com\",\"q@gmail.com\"]";
$array_of_data=json_decode($json_string);

輸出

這將生成以下輸出 −

Array("m@gmail.com","p@gmail.com","q@gmail.com")

更新日期:2020 年 4 月 6 日

348 次瀏覽

開啟您的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.