array.php ➔ htmlParser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
  function utf8ize($_array) {
3
    return travelStringArray($_array,"utf8_encode");
4
  }
5
  function unutf8ize($_array) {
6
    return travelStringArray($_array,"utf8_decode");
7
  }
8
  function arraySlash($_array) {
9
    return travelStringArray($_array,"addslashes");
10
  }
11
  function arrayHtmlParser($_array) {
12
    return travelStringArray($_array,"htmlParser");
13
  }
14
  function travelStringArray ( $_array, $_function ) {
15
    if (is_array($_array)) {
16
      foreach ($_array as $k => $v) {
17
        $_array[$k] = travelStringArray($v, $_function);
18
      }
19
    } else if (is_string ($_array)) {
20
      return call_user_func($_function,$_array);
21
    }
22
    return $_array;
23
  }
24
  function arrayDepth( $_array ) {
25
    $maxDepth = 1;
26
    foreach ($_array as $value) {
27
      if (is_array($value)) {
28
        $depth = arrayDepth($value) + 1;
29
        if ($depth > $maxDepth) {
30
          $maxDepth = $depth;
31
        }
32
      }
33
    }
34
    return $maxDepth;
35
  }
36
  function arrayDump( $_array, $_name = "Array", $_tab = "&nbsp;&nbsp;" ) {
37
    $position = preg_replace('/&nbsp;&nbsp;/', '', $_tab, 1);
38
    echo "$position<span style=\"color:rgb(230,0,0)\">$_name:</span><br>";
39
    foreach ($_array as $k => $i)
40
      if(is_array($i))
41
        arrayDump( $i, $k, "&nbsp;&nbsp;$_tab" );
42
      else if(is_object($i))
43
        echo "$_tab<b>object:</b> [Object]<br>";
44
      else
45
        echo "$_tab<b>$k:</b> $i<br>";
46
  }
47
48
  function htmlParser( $_str) {
49
    return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8");
50
  }
51
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
52