Hello I am setting a key value pair in an array in a foreach loop
e.g
array(2) {
[0]=>
array(1) {
["resourceType"]=>
string(4) "File"
["resourceName"]=>
string(4) "Test"
[1]=>
array(1) {
["resourceType"]=>
string(4) "File"
["resourceName"]=>
string(4) "Test"
}
I am doing this via a foreach loop
foreach ($output as $data) {
$resourceType = strpos($data, "d");
if ($resourceType) {
$ftpArray[]['resourceType'] = "Folder";
} else {
$ftpArray[]['resourceType'] = "File";
}
$resourceName = strrchr($data, " ");
$resourceName = trim($resourceName);
if ($resourceName != ".." && $resourceName != "." && $resourceName != "") {
$ftpArray[]['resourceName'] = $resourceName;
}
}
But the output is this
[0]=>
array(1) {
["resourceType"]=>
string(4) "File"
}
[1]=>
array(1) {
["resourceType"]=>
string(4) "Test"
}
[2]=>
array(1) {
["resourceType"]=>
string(4) "File"
}
[3]=>
array(1) {
["resourceName"]=>
string(9) ".htaccess"
}
Rather than the example I gave at the start of the question. How can I get the array to fill in key values pairs like the first example.