I generated ol or menus list item and testing work very well in localhost but when I upload to hosting I got errors:
Parse error: syntax error, unexpected T_FUNCTION
I double checked in my code and in localhost it still work. Please help what is wrong with my code.
function generate_li($product, $parent = NULL) {
$li = "";
$p1 = array_filter($product, function($a)use($parent) {
return $a['parent_id'] == $parent;
});
foreach ($p1 as $p) {
$inner_li = "";
$p2 = array_filter($product, function($a)use($p) {
return $a['parent_id'] == $p['id'];
});
if ($p2) {
$inner_li = $this->generate_li($product, $p['id']);
}
$li .= "<li class='dd-item' data-id='" . $p['id'] . "'><div class='dd-handle'>" . $p['text'] . "</div>" . $inner_li . "";
$li .= '<div class="m3dd-handle"><a href="' . base_url('menu_add/' . $p['id'] . '/' . $p['id']) . '">Add</a></div>';
$li .= '<div class="mdd-handle"><a href="' . base_url('menu_edit/' . $p['relative']) . '">';
$li .= '<span class="mclose glyphicon glyphicon-edit"></span></a></div>';
$li .= '<div class="m2dd-handle"><a onclick="return confirm(' . "'" . 'Are you sure want to delete this item' . "'" . ')" href="' . base_url('menu_delete/' . $p['id']) . '"><span class="mclose glyphicon glyphicon-remove"></span></a></div>';
$li .= "</li>";
}
$ol = "<ol class='dd-list'>" . $li . "</ol>";
return $ol;
}