title: AWS SQS How to parse message
body: <p>This is the code that receives a message from an AWS S3 Bucket event.</p>
  
  <pre><code>include_once('../aws/aws-autoloader.php');
  include_once('AWSMsgQueueUserActivity.php');
  include_once('AWSMsgQueueS3.php');
  
  
  use Aws\Sqs\SqsClient;
  use Aws\Exception\AwsException;
  use Aws\Credentials\Credentials;
  
  //$receive = new AWSMsgQueueUserActivity();
  $receive = new AWSMsgQueueS3();
  
  do
  {
      //sleep(1);
      $result = $receive-&gt;getMessage();
     // print_r('\n');
  
      if (count($result-&gt;get('Messages')) &gt; 0) {
  
          $msg = $result-&gt;get('Messages')[0];
          $decode_msg = json_decode($msg["Body"],true);
          var_dump($decode_msg);
  
          $receive-&gt;deleteMessage($result-&gt;get('Messages')[0]['ReceiptHandle']);
      }
   else{
       //echo "No Message In Queue\n";
   }
  
  } while (true);
  </code></pre>
  
  <p>This is the output of the var_dump. The json_decode was passed true as its second parameter so, got back an array.</p>
  
  <pre><code>array(1) {
    ["Records"]=&gt;
    array(1) {
      [0]=&gt;
      array(9) {
        ["eventVersion"]=&gt;
        string(3) "2.1"
        ["eventSource"]=&gt;
        string(6) "aws:s3"
        ["awsRegion"]=&gt;
        string(9) "us-east-1"
        ["eventTime"]=&gt;
        string(24) "2019-06-30T18:26:49.428Z"
        ["eventName"]=&gt;
        string(17) "ObjectCreated:Put"
        ["userIdentity"]=&gt;
        array(1) {
          ["principalId"]=&gt;
          string(13) "ANRN8QDWGH20Q"
        }
        ["requestParameters"]=&gt;
        array(1) {
          ["sourceIPAddress"]=&gt;
          string(13) "69.14.165.122"
        }
        ["responseElements"]=&gt;
        array(2) {
          ["x-amz-request-id"]=&gt;
          string(16) "21D1A6ADF98A39B0"
          ["x-amz-id-2"]=&gt;
          string(76) "9G957u6trQA+Q6VjxwfZy6Q+0OKppD8vjwiPr8ESDXqnUXm4uaX76gsKF9rRsWEqjphcdOjjxTc="
        }
        ["s3"]=&gt;
        array(4) {
          ["s3SchemaVersion"]=&gt;
          string(3) "1.0"
          ["configurationId"]=&gt;
          string(24) "shiftproviderbucketevent"
          ["bucket"]=&gt;
          array(3) {
            ["name"]=&gt;
            string(13) "shiftprovider"
            ["ownerIdentity"]=&gt;
            array(1) {
              ["principalId"]=&gt;
              string(13) "ANRN8QDWGH20Q"
            }
            ["arn"]=&gt;
            string(26) "arn:aws:s3:::shiftprovider"
          }
          ["object"]=&gt;
          array(4) {
            ["key"]=&gt;
            string(16) "presignedurl.php"
            ["size"]=&gt;
            int(774)
            ["eTag"]=&gt;
            string(32) "21308bd245239e3a72bdd1c78c087f1a"
            ["sequencer"]=&gt;
            string(18) "005D18FEE953EB0DD0"
          }
        }
      }
    }
  </code></pre>
  
  <p>My question is this:</p>
  
  <p>What is the best approach to handling this array so I can easily access elements inside. I want to be able to get just as an example the value of 
            ["key"]=>
            string(16) "presignedurl.php"</p>
  
  <p>and generally easily access other array elements without iterating through the whole array. Is this possible ? Any recommendations. Examples would be great. Thanks in advance in for help - I've searched for examples and tutorials and can't find anything that helps.</p>