fork download
  1. <?php
  2.  
  3. $arr = [
  4. ['TAG' => 'Peter', 'DATA' => 'happy123'],
  5. ['TAG' => 'Sam', 'DATA' => 'dog11111'],
  6. ];
  7.  
  8. echo getDataByTag($arr, 'Sam');
  9.  
  10. function getDataByTag($arr, $tag){
  11. foreach($arr as $data){
  12. if($data['TAG'] == $tag)
  13. return $data['DATA'];
  14. }
  15. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
dog11111