Following is the code
print_r($_POST).'<br><br>';
foreach($_POST as $key => $value){
if(is_array($value))
{
foreach($value as $key => $value)
{
echo "<br><br>".$key." ".$value."<br>";
}
}
echo "<br>";
}
Output is
Array ( [Cake_on_Name] => Array ( [0] => Rachana [1] => Sarika [2] => Pratik ) [Cake_on_Date] => Array ( [0] => 2017-12-19 [1] => 2017-12-19 [2] => 2017-12-19 ) [Cake_on_Time] => Array ( [0] => 10 A.M [1] => 10 A.M [2] => 10 A.M ) [Cake_Receiver_Name] => Array ( [0] => [1] => [2] => Ashvin Ade ) [Cake_on_Address] => Array ( [0] => [1] => [2] => Amravati ) [pincode] => Array ( [0] => 444607 [1] => 444607 [2] => 444607 ) [cheu] => 1-1@500,54-1@1000,65-1@1000,54-1@300,56-1@1000,65-1@300,54-1@1000 [clientinput] => Add Detail & Buy )
0 Rachana
1 Sarika
2 Pratik
0 2017-12-19
1 2017-12-19
2 2017-12-19
0 10 A.M
1 10 A.M
2 10 A.M
0
1
2 Ashvin Ade
0
1
2 Amravati
0 444607
1 444607
2 444607
But I Want Output as :
0 Rachana
0 2017-12-19
0 10 A.M
0
0
0 444607
1 Sarika
1 2017-12-19
1 10 A.M
1
1
1 444607
2 Pratik
2 2017-12-19
2 10 A.M
2 Ashvin Ade
2 Amravati
2 444607
You put it in <pre>
tags.
echo '<pre>' . print_r( $_POST, 1 ) . '</pre>';
This only displays this way in html. From the command line or if the document is formatted as plaintext, it already prints with line breaks. From a web page output, you can also do:
//this will also show all other content as standard text with line breaks.
header('Content-Type: text/plain');
You can try this.
$length = count($_POST["Cake_on_Name"]);
for($i=0; $i<=$length;$i++) {
foreach($_POST as $key => $value)
{
echo $i ." ". $value[$i]."<br>";
}
}
You could use array_map
and iterate over the result.
$zipped = array_map(null, ...array_values($_POST));
foreach ($zipped as $item) {
foreach ($item as $index => $value) {
echo $index . ' ' . $value;
}
}