Skip to content

Instantly share code, notes, and snippets.

@invalidusrname
Last active April 3, 2019 20:53
Show Gist options
  • Save invalidusrname/224271 to your computer and use it in GitHub Desktop.
Save invalidusrname/224271 to your computer and use it in GitHub Desktop.
can't remember this one
<?php
function markup_list($data, $path, $use_links = true) { // can handle 1 or 2d array
// array_flip($columns);
$output .= "<div class=\"classlist\">\n";
foreach ($data as $var => $val) {
$target_kv = explode("=", $var); // break up compound string into key/value
if ($use_links) {
$output .= '<p><a href="'.$path.'?'.$target_kv[0].'='.$target_kv[1].'">'.$target_kv[1]."</a></p>\n";
}
else {
$output .= '<p>' . $target_kv[1] . "</p>\n";
}
if (is_array($val)) {
$output .= "<ul class=\"proflist\">\n";
foreach ($data[$var] as $var2 => $val2) {
$list_kv = explode("=", $val2); // break up compound string into key/value
if ($use_links) {
$output .= '<li><a href="'.$path.'?'.$list_kv[0].'='.$list_kv[1].'">'.$list_kv[1]."</a></li>\n";
}
else {
$output .= '<li>' . $list_kv[1] . "</a></li>\n";
}
}
$output .= "</ul>\n";
}
}
$output .= "</div>\n";
return $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment