skip to Main Content

Here is my array and i get only name from that array so how can i get it

[
 {
  "name":"imgpsh_fullsize_anim_31.png",
  "type":"image/png",
  "tmp_name":"/tmp/phpcaGk0O",
  "error":"0",
  "size":"34171",
  "file":"imgpsh_fullsize_anim_31.png",
  "cookie":
  {
   "name":"admin",
   "value":"s3jbpiubqq13tsrase0d4e6cma",
   "lifetime":"900000",
   "path":"/nback",
  },
  "previewType":"image"
  }
 ]

2

Answers


  1. I assume this is a JSON string you have in your hands so basically:

    $arr = json_decode($str, true);
    $name = $arr[0]["name"];
    
    Login or Signup to reply.
  2. If you call your array $myArray you would extract only the variable name like so:

    $name = $myArray->name;
    

    And if it’s JSON:

    $myJSONArray = json_decode($myArray);
    $name = $myJSONArray[0]["name"];
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search