1

I have this loop, where I'm trying to generate an array like this:

array( $file['file_type'] => $file['import_status] )

To do so, I build this foreach loop to access the $file variable, which has the data I wanted to store.

$filesStatusArray = array();
foreach ($filesToImport as $keys => $file) {
    $filesStatusArray = $file['import_status'];
}

This way I'm doing, I have only an array with the import_status values.. but I wanted the key to be the file_type... how can I do that?

1
  • Probably best to show the structure of the $filesToImport array and the desired structure of $fileStatusArray Commented Nov 28, 2013 at 2:10

1 Answer 1

1
$filesStatusArray = array();
foreach ($filesToImport as $keys => $file) {
    $filesStatusArray[$file['file_type']] = $file['import_status'];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.