tags:

views:

49

answers:

3

The following function out-puts an array and html.

I don't want to have

<li><a href="http://127.0.0.1/ci_okadadesign/index.php/admin/menus/r"&gt;r&lt;/a&gt;&lt;/li&gt;

Could anyone tell me how to achive it please?

Function

function getTopMenus(){
     $data[0] = 'root';
     $this->db->where('parentid',0);
     $Q = $this->db->get('menus');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[] = $row;
       }
    }
    $Q->free_result();  
    return $data; 
 }

print_r():

Array (
    [0] => Array (
            [id] => 24
            [name] => Main menu
            [shortdesc] => mainmenu
            [status] => active
            [parentid] => 0
        )
    [1] => Array (
            [id] => 25
            [name] => Galleri 1
            [shortdesc] => galleri1
            [status] => active
            [parentid] => 0
        )
)

HTML:

<li><a href="http://127.0.0.1/ci_okadadesign/index.php/admin/menus"&gt;menus&lt;/a&gt;
  <ul>
    <li><a href="http://127.0.0.1/ci_okadadesign/index.php/admin/menus/r"&gt;r&lt;/a&gt;&lt;/li&gt;
    <li><a href="http://127.0.0.1/ci_okadadesign/index.php/admin/menus/mainmenu"&gt;Main menu</a></li>
    <li><a href="http://127.0.0.1/ci_okadadesign/index.php/admin/menus/galleri1"&gt;Galleri 1</a></li>
  </ul>
+2  A: 

Looks like you have a bunch of menu items defined in your database. If there's a menu item in there titled 'r' all you have to do is delete that row and that <li> will go away.

Chuck Vose
A: 

array_shift() is what you want

SleighBoy
A: 

Are you using CodeIgniter? You can refine the query saved in $Q using get_where instead of get (see CodeIgniter User Guide).

dusan