php: build a HTML ul - li list from an associative array
2019-10-01
Q: how to build an <ul>..<li>
list on an array with php?
A: use the recursive function below for creation.
/**
* @param array $aData
* @return string $sMarkup Markup <ul>..<li> List
*/
function buildMarkupListTree($aData)
{
if (false === is_array($aData))
{
return '';
}
$sMarkup = '<ul>';
foreach ($aData as $sKey => $mValue)
{
$sMarkup.= '<l […]
php: beautify var_export
2019-09-24
Die Ausgabe von var_export()
aufgehübscht.
Mit Rückgabe von array(..)
als Array Indikator
// prettify var_dump array
$sExport = var_export($mData, true);
$sExport = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $sExport);
$aData = preg_split("/\r\n|\n|\r/", $sExport);
$aData = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ')$1', ' => array('], $aData);
$sExport = join(PHP_EOL […]