Go to the source code of this file.
Functions | |
getHtmlArray (&$arr_) | |
Return an humanredable html table representation of a php array. | |
_getHtmlArrayHeader ($count_) | |
Helper function for getHtmlArray(). | |
_getHtmlArrayBody ($key_, $val_) | |
Helper function for getHtmlArray(). | |
_getHtmlArrayInnerArray ($key_, $val_) | |
Helper function for getHtmlArray(). | |
getVarContent ($val_) | |
Return a human readable text output of a variable. | |
getHtmlArrayPhp ($arr_, $rowPrefix_= '') | |
Return a "php-coded" representation of a php array. | |
array_diff_assoc_recursive ($array1, $array2) | |
Computes the difference of arrays with additional index check. |
Definition in file Array.php.
_getHtmlArrayBody | ( | $ | key_, | |
$ | val_ | |||
) | [private] |
Helper function for getHtmlArray().
Definition at line 68 of file Array.php.
References getVarContent().
Referenced by getHtmlArray().
00069 { 00070 $result = '<tr>'; 00071 00072 $result .= '<td>' . $key_ . '</td>'; 00073 $result .= '<td>' . getVarContent($val_) . '</td>'; 00074 $result .= '<td>' . gettype($val_) . '</td>'; 00075 00076 if (is_string($val_)) 00077 { 00078 $result .= '<td>' . strlen($val_) . '</td>'; 00079 } 00080 else 00081 { 00082 $result .= '<td>' . sizeof($val_) . '</td>'; 00083 } 00084 00085 $result .= '</tr>'; 00086 00087 return $result; 00088 }
_getHtmlArrayHeader | ( | $ | count_ | ) | [private] |
Helper function for getHtmlArray().
Definition at line 47 of file Array.php.
Referenced by getHtmlArray().
00048 { 00049 $result .= '<tr>'; 00050 $result .= '<td colspan="4">Count:' . $count_ . '</td>'; 00051 $result .= '</tr>'; 00052 00053 $result .= '<tr>'; 00054 $result .= '<td>key</td>'; 00055 $result .= '<td>value</td>'; 00056 $result .= '<td>type</td>'; 00057 $result .= '<td>size</td>'; 00058 $result .= '</tr>'; 00059 00060 return $result; 00061 }
_getHtmlArrayInnerArray | ( | $ | key_, | |
$ | val_ | |||
) | [private] |
Helper function for getHtmlArray().
Definition at line 95 of file Array.php.
References getHtmlArray().
Referenced by getHtmlArray().
00096 { 00097 static $sNumberOfLevels = 0; 00098 00099 $result = '<tr>'; 00100 $result .= '<td>' . $key_ . '</td>'; 00101 $result .= '<td colspan="3">'; 00102 00103 if ($sNumberOfLevels > 15) 00104 { 00105 $result .= ' To many levels for debug output '; 00106 } 00107 else 00108 { 00109 $sNumberOfLevels++; 00110 $result .= getHtmlArray($val_); 00111 $sNumberOfLevels--; 00112 } 00113 00114 $result .= '</td>'; 00115 $result .= '</tr>'; 00116 00117 return $result; 00118 }
array_diff_assoc_recursive | ( | $ | array1, | |
$ | array2 | |||
) |
Computes the difference of arrays with additional index check.
Copied from http://se.php.net/manual/en/function.array-diff-assoc.php#73972
Definition at line 235 of file Array.php.
Referenced by FOUnitTestBase::_isEqualArray().
00236 { 00237 foreach($array1 as $key => $value) 00238 { 00239 if(is_array($value)) 00240 { 00241 if(!is_array($array2[$key])) 00242 { 00243 $difference[$key] = $value; 00244 } 00245 else 00246 { 00247 $new_diff = array_diff_assoc_recursive($value, $array2[$key]); 00248 if($new_diff != FALSE) 00249 { 00250 $difference[$key] = $new_diff; 00251 } 00252 } 00253 } 00254 else 00255 { 00256 if (gettype($array2[$key]) == 'double' || gettype($array2[$key]) == 'float') 00257 { 00258 $array2[$key] = (double)((string)$array2[$key]); 00259 } 00260 00261 if (gettype($value) == 'double' || gettype($value) == 'float') 00262 { 00263 $value = (double)((string)$value); 00264 } 00265 00266 if((!is_array($array2) || !array_key_exists($key, $array2)) || (isset($array2[$key]) && isset($value) && $array2[$key] != $value)) 00267 { 00268 $difference[$key] = $value; 00269 } 00270 } 00271 } 00272 return !isset($difference) ? 0 : $difference; 00273 }
getHtmlArray | ( | &$ | arr_ | ) |
Return an humanredable html table representation of a php array.
Definition at line 15 of file Array.php.
References _getHtmlArrayBody(), _getHtmlArrayHeader(), and _getHtmlArrayInnerArray().
Referenced by _getHtmlArrayInnerArray().
00016 { 00017 $result = ''; 00018 if (is_array($arr_)) 00019 { 00020 $result_ .= '<table border="1" cellspacing="0" cellpadding="3">'; 00021 00022 $result_ .= _getHtmlArrayHeader(count($arr)); 00023 00024 foreach ($arr_ as $key => $val) 00025 { 00026 if (is_array($val)) 00027 { 00028 $result_ .= _getHtmlArrayInnerArray($key, $val); 00029 } 00030 else 00031 { 00032 $result_ .= _getHtmlArrayBody($key, $val); 00033 } 00034 } 00035 00036 $result_ .= '</table>'; 00037 } 00038 00039 return $result_; 00040 }
getHtmlArrayPhp | ( | $ | arr_, | |
$ | rowPrefix_ = '' | |||
) |
Return a "php-coded" representation of a php array.
Example of output
array ( 'first_name' => 'Daniel', 'last_name' => 'Lindh', 'age' => 32 )
Definition at line 173 of file Array.php.
References getVarContent().
Referenced by standard::_writeReturnVariable().
00174 { 00175 if (is_array($arr_)) 00176 { 00177 $currentRowPrefix = ''; 00178 $str = 'array' . "<br/>" . $rowPrefix_ . '(' . "<br/>"; 00179 foreach ($arr_ as $key => $row) 00180 { 00181 if (!empty($currentRowPrefix)) 00182 { 00183 $str .= ",<br/>"; 00184 } 00185 00186 $currentRowPrefix = $rowPrefix_ . " " . '\'' . $key . '\' => '; 00187 00188 if (is_string($row)) 00189 { 00190 $arr = unserialize($row); 00191 if ($arr) 00192 { 00193 $row = $arr; 00194 } 00195 } 00196 00197 if (is_array($row)) 00198 { 00199 $recursiveStr = getHtmlArrayPhp($row, $rowPrefix_ . " "); 00200 if (empty($recursiveStr)) 00201 { 00202 $recursiveStr = 'array()'; 00203 } 00204 00205 $str .= $currentRowPrefix . $recursiveStr; 00206 } 00207 elseif (is_object($row)) 00208 { 00209 $str .= $currentRowPrefix . '\'class: ' . get_class($row) . '\'' ; 00210 } 00211 elseif (is_string($row)) 00212 { 00213 $str .= $currentRowPrefix . '\'' . $row . '\'' ; 00214 } 00215 else 00216 { 00217 $str .= $currentRowPrefix . getVarContent($row); 00218 } 00219 } 00220 $str .= "<br/>" . $rowPrefix_ . ')'; 00221 } 00222 00223 return $str; 00224 }
getVarContent | ( | $ | val_ | ) |
Return a human readable text output of a variable.
A "false" variable will get the output "FALSE" in text. An unsigned variable will get the output "NULL" in text. An empty string variable will get the output "EMPTY" in text.
Definition at line 129 of file Array.php.
References emptyString().
Referenced by _getHtmlArrayBody(), and getHtmlArrayPhp().
00130 { 00131 if (is_null($val_)) 00132 { 00133 $ret = 'NULL'; 00134 } 00135 else if (empty($val_) && is_bool($val_)) 00136 { 00137 $ret = 'FALSE'; 00138 } 00139 else if (emptyString($val_) && !is_int($val_)) 00140 { 00141 $ret = 'EMPTY'; 00142 } 00143 else if (is_string($val_)) 00144 { 00145 $ret = htmlspecialchars($val_); 00146 } 00147 else if (is_object($val_)) 00148 { 00149 $ret = 'class:' . get_class($val_); 00150 } 00151 else 00152 { 00153 $ret = $val_; 00154 } 00155 00156 return $ret; 00157 }