From 483e91e27f737f304d6424500b4081cee32a1599 Mon Sep 17 00:00:00 2001 From: Banana Date: Mon, 3 Jan 2022 10:50:16 +0100 Subject: [PATCH] an example of paths to array and json --- single-functions/paths-to-assoc-array.php | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 single-functions/paths-to-assoc-array.php diff --git a/single-functions/paths-to-assoc-array.php b/single-functions/paths-to-assoc-array.php new file mode 100644 index 0000000..ac0702e --- /dev/null +++ b/single-functions/paths-to-assoc-array.php @@ -0,0 +1,59 @@ + $value, "children" => array()); + $_w = &$_w[$value]["children"]; + } + else { + $_w = &$_w[$value]["children"]; + } + } + + $_w = &$out; + + /* + $count++; + if($count > 10) { + var_dump($out); + exit(); + } + */ + } + fclose($handle); +} else { + // error opening the file. + echo "error opening the file"; +} + +//var_dump($out); +file_put_contents("out.json", json_encode($out, JSON_PRETTY_PRINT)); -- 2.39.5