Last active
April 3, 2019 20:53
-
-
Save invalidusrname/224271 to your computer and use it in GitHub Desktop.
can't remember this one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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