Q:

PHP Search Multi Dimensional Array

I have two functions that I am working with. The first one does a database call and grabs two attributes of a user. The UserID and Markup for that user. 
/*
  Search Markup for a specific QID
*/
function searchMarkup($identifier){

  global $markupArray;

  if(isset($markupArray)){
    foreach($markupArray as $m){
      if((string)$key->QID == (string)$identifier){
        return $m->markup;
      }
    }
  }
  return '';
}

/*
  Fetch the markup data for this dashboard
*/
function fetchMarkup(){

  global $dashboardID;
  global $markupArray;

  $objDB = new DB;
  $objMarkup = $objDB
    -> setStoredProc('FetchMarkup')
    -> setParam('dashboardID', $dashboardID)
    -> execStoredProc()
    -> parseXML();

  // Create an array of the markup
  if(isset($objMarkup->data)){
    $i = 0;
    foreach($objMarkup->data as $m){
      $markup[$i] = array();
      $markup[$i]['QID'] = (string)$m->QID;
      $markup[$i]['markup'] = (string)$m->Markup;
      $i++;
    }
    $markupArray = $markup;
  }
}

When I run fetchMarkup() and then print out $markupArray, I get the result of:
Array
(
    [0] => Array
        (
            [QID] => Q0002
            [markup] => success
        )

    [1] => Array
        (
            [QID] => Q101
            [markup] => success
        )

    [2] => Array
        (
            [QID] => Q200
            [markup] => info
        )

)

My next step is to be able to search that array by providing a QID and having it return the markup value to me.
I am trying to so something like searchMarkup('Q0002') to have it tell me the result of markup but I am not getting any response.
How could I go about retrieving the value of markup from the array that is created by fetchMarkup() ?

A:

why you are using $key ? which came from no where
foreach($markupArray as $m)

as you can see you alias $m not $key
And $markupArray is an associated array not an object array
So instead of 
if((string)$key->QID == (string)$identifier){
    return $m->markup;
}

since it is an associated array change it to
if((string)$key['QID'] == (string)$identifier){
    return $m['markup'];
}

So your searchMarkup would be like this
function searchMarkup($identifier){

  global $markupArray;

  if(isset($markupArray)){
    foreach($markupArray as $m){
      if((string)$m['QID'] == (string)$identifier){
        return $m['markup'];
      }
    }
  }
  return '';
}

Demo

