Q_evans
asked on
PHP- Writing $_Post array to CSV
Afternoon
I hope you can help me, I am new to PHP,
I have posted an Array to a .php file as below.
Array
(
[id] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
[S1] => Array
(
[0] => AW01
[1] => AW01
[2] => AW02
[3] => AW03
)
[S2] => Array
(
[0] => 1234
[1] => 4567
[2] => 9874
[3] => 1265
)
[S3] => Array
(
[0] => 1
[1] => 1
[2] => 2
[3] => 5
)
[S5] => Array
(
[0] =>
[1] => yui
[2] =>
[3] =>
)
[S6] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
)
[S4] => Array
(
[0] => 1
[1] => 1
)
[FormSubmit] => Submit
)
I want to write the Array to a CSV file So i can read it as
ID S1 S2 S3 S4 S5 S6
1 AW01 1234 1 1 yui
2 AW01 4567 1 1
3 etc
4 etc
I hope you can help as i have been going through this for Days and days without any luck.
Thanks in Advance.
I hope you can help me, I am new to PHP,
I have posted an Array to a .php file as below.
Array
(
[id] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
[S1] => Array
(
[0] => AW01
[1] => AW01
[2] => AW02
[3] => AW03
)
[S2] => Array
(
[0] => 1234
[1] => 4567
[2] => 9874
[3] => 1265
)
[S3] => Array
(
[0] => 1
[1] => 1
[2] => 2
[3] => 5
)
[S5] => Array
(
[0] =>
[1] => yui
[2] =>
[3] =>
)
[S6] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
)
[S4] => Array
(
[0] => 1
[1] => 1
)
[FormSubmit] => Submit
)
I want to write the Array to a CSV file So i can read it as
ID S1 S2 S3 S4 S5 S6
1 AW01 1234 1 1 yui
2 AW01 4567 1 1
3 etc
4 etc
I hope you can help as i have been going through this for Days and days without any luck.
Thanks in Advance.
ASKER
Hi Chris Thanks for that.
The Posted Array will change everytime as it is taken from a table from the page before.
So yes this works great, although I need the Arrays from the $_Post array. to be wirtten to the CSV? I hope this makes sense.
Regards
The Posted Array will change everytime as it is taken from a table from the page before.
So yes this works great, although I need the Arrays from the $_Post array. to be wirtten to the CSV? I hope this makes sense.
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$_Post is probably not correct. Variable names are case-sensitive in PHP, so you probably want $_POST.
If you want to show us the HTML form that is used to gather the data we might be able to test a little better.
If you want to show us the HTML form that is used to gather the data we might be able to test a little better.
ASKER
Thanks ChrisStanyon, Works a treat...
Open in new window