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
https://forums.phpfreaks.com/topic/204901-2-dimensional-variable-variable-array/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.