差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
php:json [2022/05/31 22:35] – 作成 baba | php:json [2022/05/31 22:42] (現在) – [Reference] baba | ||
---|---|---|---|
行 1: | 行 1: | ||
====== php でjsonのread and write ====== | ====== php でjsonのread and write ====== | ||
phpでのjsonファイル読み込みと書き出しの超速レシピ用メモ | phpでのjsonファイル読み込みと書き出しの超速レシピ用メモ | ||
+ | |||
+ | ===== Write ===== | ||
+ | < | ||
+ | $obj = '{ " | ||
+ | $data = json_decode($obj, | ||
+ | |||
+ | $json = fopen(' | ||
+ | fwrite($json, | ||
+ | fclose($json); | ||
+ | </ | ||
+ | |||
+ | ===== Read ===== | ||
+ | < | ||
+ | $json_string = file_get_contents(" | ||
+ | $json_string_encoded = mb_convert_encoding($json_string, | ||
+ | $json_decoded = json_decode($json_string_encoded, | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Reference ===== | ||
+ | * https:// | ||
+ | * https:// | ||