area.php 545 B

123456789101112131415161718
  1. <?php
  2. $data = [];
  3. $list = json_decode(file_get_contents(__DIR__ . '/area.json'), true);
  4. foreach ($list as $citys) {
  5. $lines = [];
  6. foreach ($citys['list'] as $area) {
  7. $lines[] = $area['name'] . ',' . join(',', $area['list']);
  8. }
  9. $data[] = $citys['name'] . '$' . join('|', $lines);
  10. }
  11. $filename = dirname(__DIR__) . '/pcasunzips.js';
  12. $content = str_replace('__STRING__', join('#', $data), file_get_contents(__DIR__ . '/area.js'));
  13. if (file_put_contents($filename, $content)) {
  14. echo 'success';
  15. } else {
  16. echo 'error';
  17. }