Helpers.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. if (!function_exists('toHumanReadable')) {
  3. function toHumanReadable($name)
  4. {
  5. return ucwords(preg_replace("/[^0-9a-z]/i", " ", $name));
  6. }
  7. }
  8. if (!function_exists('parseRender')) {
  9. function parseRender($_data)
  10. {
  11. if ($_data) {
  12. $type = gettype($_data);
  13. if (is_string($_data) || is_numeric($_data)) {
  14. echo $_data;
  15. } else {
  16. echo "<table class='table table-sm border w-100'>";
  17. foreach ($_data as $k => $v) {
  18. echo "<tr>";
  19. echo "<td><b class='text-secondary'>" . toHumanReadable($k) . "</b></td>";
  20. echo "<td>";
  21. if (is_object($v)) {
  22. parseRender($v);
  23. } elseif (is_array($v)) {
  24. foreach ($v as $k2 => $v2) {
  25. parseRender($v2);
  26. }
  27. } else {
  28. echo $v;
  29. }
  30. echo "</td>";
  31. echo "</tr>";
  32. }
  33. echo "</table>";
  34. }
  35. }
  36. }
  37. }
  38. ?>