Jump to content

Surely a simple problem...


ViperSBT

Recommended Posts

OK, I pass an array from another page, I then use the following code to handle the array:[code]foreach($states as $state){
echo $state;}[/code]
I would expect to get each of the states in the array returned, instead what I get is:
[quote]ArrayArrayArrayArray[/quote]
So, why isn't the array being parsed?  If I do print_r($states) I can see each of the elements in the array and they hold the correct value...  So it seems the foreach isn't doing what it is supposed.
Link to comment
Share on other sites

[quote author=ViperSBT link=topic=106096.msg424057#msg424057 date=1156865065]
OK, I pass an array from another page, I then use the following code to handle the array:[code]foreach($states as $state){
echo $state;}[/code]
I would expect to get each of the states in the array returned, instead what I get is:
[quote]ArrayArrayArrayArray[/quote]
So, why isn't the array being parsed?  If I do print_r($states) I can see each of the elements in the array and they hold the correct value...  So it seems the foreach isn't doing what it is supposed.
[/quote]
as jenk said, your values are being held within another level of arrays, so you need to access them that way. looks like you could probably simply do the following:
[code]
<?php
foreach ($states as $state) echo "$state[1]<br />\n";
?>
[/code]
Link to comment
Share on other sites

The $states array is bein gbuilt from a Mutli-Seelction List field on a prior page.  The select which states they want to see a report for.[code]<select multiple name='states[]' size='10'>
<option value='All' SELECTED>All States/Provinces</option>
<?
foreach ($statelist as $key => $value) {
echo "<option value='" .$key."'>$statelist[$key]</option>\n";
}
?></select>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.