Bruce Gust
asked on
How would I print this array?
Here's my array when I do a var_dump:
C:\wamp64\www\adm\jquery_p ost.php:9:
array (size=2)
'comparison_value' =>
array (size=1)
0 => string 'asdf' (length=4)
'between_value' =>
array (size=1)
0 => string 'fghj' (length=4)
I want to be able to print out:
comparison_value = asdf
between_value=fghi
How?
C:\wamp64\www\adm\jquery_p
array (size=2)
'comparison_value' =>
array (size=1)
0 => string 'asdf' (length=4)
'between_value' =>
array (size=1)
0 => string 'fghj' (length=4)
I want to be able to print out:
comparison_value = asdf
between_value=fghi
How?
ASKER
That gives me this:
comparison_value = Array
between_value = Array
# | Time | Memory | Function | Location |
---|---|---|---|---|
Call Stack | ||||
( ! ) Notice: Array to string conversion in C:\wamp64\www\adm\jquery_post.php on line 13 | ||||
1 | 0.0009 | 414008 | {main}( ) | ...\jquery_post.php:0 |
# | Time | Memory | Function | Location |
---|---|---|---|---|
Call Stack | ||||
( ! ) Notice: Array to string conversion in C:\wamp64\www\adm\jquery_post.php on line 13 | ||||
1 | 0.0009 | 414008 | {main}( ) | ...\jquery_post.php:0 |
ASKER
BTW: Here's the form from which all of this is coming:
<form action="jquery_post.php" method="Post">
<input type="text" name="criteria[comparison_value][]"><br>
<input type="text" name="criteria[between_value][]">
<input type="submit" value="submit">
</form>
Not the way I usually put a form together, but that's the infrastructure I'm dealing with and that's what results in the "var_dump" you see above.
Thanks!
<form action="jquery_post.php" method="Post">
<input type="text" name="criteria[comparison_value][]"><br>
<input type="text" name="criteria[between_value][]">
<input type="submit" value="submit">
</form>
Not the way I usually put a form together, but that's the infrastructure I'm dealing with and that's what results in the "var_dump" you see above.
Thanks!
What's the array name?
ASKER
Here's the code:
<?php
var_dump($_POST['criteria']);
echo "<br><br>";
foreach ( $_POST['criteria'] as $key => $value )
{
echo "$key = $value\n";
}
?>
The array would be $_POST['criteria']
<?php
var_dump($_POST['criteria']);
echo "<br><br>";
foreach ( $_POST['criteria'] as $key => $value )
{
echo "$key = $value\n";
}
?>
The array would be $_POST['criteria']
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it!
Thanks!
Thanks!
Bruce
Glad that worked, curious about the second set of [] - is there a reason for them?
Without them the code you posted should work.
Glad that worked, curious about the second set of [] - is there a reason for them?
Without them the code you posted should work.
ASKER
Couldn't tell you. I'm coming in after the fact and just trying to make things work...!
No, problem.:)
Open in new window