mardi 22 avril 2014

Search an array for the specific value and return its key


Vote count:

0




I have a multidimensional array, which I want to search and returns its corresponding key so that I can again use the key and return more information from that corresponding array.


This is what my array looks like



$add_admin_menu_page = array();
$add_admin_menu_page[] = array('Dashboard', 'dashboard.php', 'dashboard');
$add_admin_menu_page[] = array('Posts', 'posts.php', 'posts');
$add_admin_menu_page[] = array('Comments', 'comments.php', 'comments');
$add_admin_menu_page[] = array('Tools', 'tools.php', 'tools');


This is what am doing currently to make it work



<?php
//global $add_admin_menu_page;
$page = "dashboard.php";
$key = array_search($page, $add_admin_menu_page);
var_dump($key);
?>


Above result outputs



bool(false)




asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire