Code Snippers/PHP: verschil tussen versies
Uit WaaaghPedia
Regel 1: | Regel 1: | ||
== Print Pre == | == Print Pre == | ||
<pre>if ( ! function_exists('print_pre')){ | |||
/** | /** | ||
* Shows print_r in the pre tags | * Shows print_r in the pre tags | ||
Regel 16: | Regel 16: | ||
} | } | ||
} | } | ||
</ | </pre> | ||
== Var_Pre == | == Var_Pre == |
Huidige versie van 13 aug 2022 om 14:38
Print Pre
if ( ! function_exists('print_pre')){ /** * Shows print_r in the pre tags * * <pre>print_r($print);</pre> * * @param string $print * @return pre string OR No data parsed */ function print_pre($print = 'No data parsed'){ echo "<pre>"; print_r($print); echo "</pre>"; } }
Var_Pre
if ( ! function_exists('var_pre')){ /** * Shows var_dump in the pre tags * * <pre>var_dump($dump);</pre> * * @param string $dump * @return pre string OR No data parsed */ function var_pre($dump = 'No data parsed'){ echo "<pre>"; var_dump($dump); echo "</pre>"; } }
XML with CDATA to ARRAY
$xml = simplexml_load_string($xmlfile, NULL, LIBXML_NOCDATA); $json = json_encode($xml, JSON_PRETTY_PRINT); $array = json_decode($json, TRUE); print_r ($array);