We help IT Professionals succeed at work.
Get Started

Array collection of files

tonelm54
tonelm54 asked
on
125 Views
Last Modified: 2016-02-26
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
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE