Link to home
Start Free TrialLog in
Avatar of 10023
10023

asked on

Php parsing csv text file with line ending "\n" to multidemensional array

I write to file  this way:
$var = "$date, $firstname,$lastname, $address, $city, $state, $zip, $product,$price\n";

File looks like below after write without star break

*************************************
date, firstname, lastname, address, city, state, zip, product, price
date, firstname, lastname, address, city, state, zip, product, price
date, firstname, lastname, address, city, state, zip, product, price
date, firstname, lastname, address, city, state, zip, product, price
*************************************

I need load each line into a $multidemensional[ ] [ ] array so that i can do this
Get lastname  by $multidemensional[$i][2] to sort by last name.

I have tried different functions without success to write out multidemensional array...i dont get an error...just no output.
here is my code to test
echo $multidemensional[1][2]."<br/>"; which does not output second row lastname.

i need the array load to multidemension function  and most efficient way to sort it..by last name
thanks

I am using php 5.3 and above
ASKER CERTIFIED SOLUTION
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 10023
10023

ASKER

Thankyou trying it out now...appears to be working..need to output sorted without using
print_r so output would be cleaner...trying for loop
Avatar of 10023

ASKER

thankyou very much...