English 中文(简体)
需要的PHP帮助将亚马孙S3格里的一组数据分配给一个变量。
原标题:Need PHP help assigning a piece of data from an Amazon S3 query to a variable

I m利用AWS PHP SDK以及以下所列代码,归还一份与我亚马孙S3服务中一台夹有关的物体清单:

$s3 = new AmazonS3();

$response = $s3->list_objects($bucket, array(
     prefix  =>  myfolder/ 
));

print_r($response->body);

我不想使用“印本”部分。

The $response seems to be an array with a bunch of stuff in it: Key, LastModified, ETag, Size, Owner

购买力平价法将采取对应措施,并将一个比值分配给一个变量。 例如,答复中的1项数据是“灰色”数据,看起来像这样:

[Key] => myfolder/myfile.pdf

我需要的是:

myfolder/myfile.pdf

请提供守则,我需要在答复费用中填写数据,并将“KEY”的每个案例分配给一个称为“haasfilepath”的变量。

Thanks!

问题回答

It has been awhile since I ve used php, but this should be work if I understand your problem. If $response is an array with each element containing an associative array for the matching object.

$hassfilepath = Array();
    foreach($response as $element){
        $haasfilepath << $element[key];
    }

每一方将允许你通过回复中归还的所有物体。 在座右边,你将每个[Key]推入“haasfilepath”的阵列。 现在,你们有一系列重要回馈。

据我所知,答复将是一个XML文件(并非一个阵列名称-价值-pair),你必须把XML文件整理起来。 Try researching xpath and similar methods in parse XMl file in php。

foreach ($response->body as $key => $haasfilepath)
{
 echo  value for key  , $key,   is  , $haasfilepath,  <br> ;
}

或者,如果你只需要关键的“关键”:

$haasfilepath = $response->body[ key ];
echo $haasfilepath;




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签