Avatar of tonelm54
tonelm54

asked on 

Array collection of files

I'm trying to make an array of files which will hold a list of files, per remittance, so in my example I have 2 remitances both of 2 pages, so in simple terms Im trying to set my array up as:-
	$remitanceCollection = array();

	array_push($remitanceCollection, $remitanceCollection[0]["files"],"Page0");
	array_push($remitanceCollection, $remitanceCollection[0]["files"],"Page1");

	array_push($remitanceCollection, $remitanceCollection[1]["files"],"Page2");
	array_push($remitanceCollection, $remitanceCollection[1]["files"],"Page3");

Open in new window


The code runs a lot more lines to get this information, so I cant use, but will get what I want.
	$remitanceCollection = array("0"=>array("Files"=>array("Page1","Page2")),"1"=>array("Files"=>array("Page3","Page4")));

Open in new window


So, my issue is 3 part:-
1 - I dont understand why I get the error - E_NOTICE : type 8 -- Undefined offset: 0 -- at line 4

2 - I dont understand the Warnings - E_WARNING : type 2 -- Illegal string offset 'files' -- at line 7 and E_WARNING : type 2 -- Illegal string offset 'files' -- at line 8

3 - The returned array after a print_r, isnt what I would have expected, where did the "P" come from? :-S:-
Array ( [0] => [1] => Page0 [2] => [3] => Page1 [4] => P [5] => Page2 [6] => P [7] => Page3 )

Any ideas what Im doing wrong in what looks like a simple task :-S

Thank you
PHP

Avatar of undefined
Last Comment
tonelm54

8/22/2022 - Mon