php - Foreach iteration not working -



php - Foreach iteration not working -

i got key values in array variable. here iterate array , execute it.

foreach ($key_details $index => $value) { # code... $result = $s3->deleteobjects(array( 'bucket' => content_bucket, 'objects' => array( array('key' => $value), ) )); }

here each time need create instance. if possible iterate this

# code... $result = $s3->deleteobjects(array( 'bucket' => content_bucket, 'objects' => array( foreach ($key_details $index => $value) { array('key' => $value), } ) )); }

you can't utilize foreach within array declaration - hence parse error: unexpected t_foreach.... instead, though, create info objects first, utilize deleteobjects parameter.

$objects = array(); foreach ($key_details $value) { $objects[] = array('key' => $value); } $result = $s3->deleteobjects(array( 'bucket' => content_bucket, 'objects' => $objects ));

php arrays

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -