how to get the value from a nested PHP array

I have this php array. how can I get the DATA value, when I only have the TAG value? For example, when my input is Peter, I want to return happy123, and when my input is Sam, I want to return dog11111

array(72) {
  array(2) {
    string(5) "Peter"
    string(8) "happy123"
  array(2) {
    string(3) "Sam"
    string(8) "dog11111"


You'll have to loop through the array and search for the matching TAG:

function getDataByTag($arr, $tag){
    foreach($arr as $data){
        if($data['TAG'] == $tag)
            return $data['DATA'];


Need Your Help

MSSQL Select statement with incremental integer column… not from a table

sql sql-server sql-server-2000 auto-increment row-number

I need, if possible, a t-sql query that, returning the values from an arbitrary table, also returns a incremental integer column with value = 1 for the first row, 2 for the second, and so on.

Prevent Backup to iCloud,is following code correct?

iphone ios backup icloud home-directory

I am downloading many audio and video files and stored them in my Home directory.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.