troubleshooting Question

Array collection of files

Avatar of tonelm54
tonelm54 asked on
PHP
3 Comments1 Solution138 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
tonelm54

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 3 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 3 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004