Drupal investigation

entities.php 636B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Fetch the entities.json file and convert to PHP datastructure.
  4. */
  5. // The URL to the official entities JSON file.
  6. $ENTITIES_URL = 'http://www.w3.org/TR/2012/CR-html5-20121217/entities.json';
  7. $payload = file_get_contents($ENTITIES_URL);
  8. $json = json_decode($payload);
  9. $table = array();
  10. foreach ($json as $name => $obj) {
  11. $sname = substr($name, 1, -1);
  12. $table[$sname] = $obj->characters;
  13. }
  14. print '<?php
  15. namespace Masterminds\\HTML5;
  16. /** Entity lookup tables. This class is automatically generated. */
  17. class Entities {
  18. public static $byName = ';
  19. var_export($table);
  20. print ';
  21. }' . PHP_EOL;
  22. //print serialize($table);