Jump to content

2 dimensional variable variable array


clay1

Recommended Posts

I am trying to sort records into 2 different 2 dimensional arrays such that I end up with something like:

 

$array1 = array("Boston" = > array(variousrecords), "New York" = > (various records));

 

So far I have:

 

$array1 = array();
$array2 = array();
   while ($recordData = pg_fetch_assoc($recordresults))
   { if (in_array($recordData['event city'], $marketsarray1)){
   $eventcity = $recordData['event city'];
   
         $$eventcity = array($recordData);}
      elseif (in_array($recordData['event city'], $marketsarray2) ){
         $$eventcity = array($recordData);}
	 else {
         $unsorted[] = $recordData;}
	 }

 

How can I make

 

 $array1[$$eventcity] = array($recordData);}

 

?

Link to comment
Share on other sites

I take that back.

 

while($ix <16){

var_dump($array2[$ix]);


$ix++;
}

var_dump($array2["Walnut Creek"]);

 

First var_dump prints out an array but the keys seem to be duplicating i.e.

 

array2("Walnut Creek" => 1 record, "Boston" => 1 record, "Walnut Creek"  => another record)

 

Rather than array2("Walnut Creek" => 5 records, "Boston" => 3 records)

 

When I do the second var_dump I get NULL

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.