[nycphp-talk] Array Transformation Assistance.

Ben Sgro (sk) skyline at
Mon Oct 2 15:10:23 EDT 2006


$master_names = array('joe', 'adam', 'alex');
$master_new   = array( );

while(list($index, $value) = each($master_names))
    $master_new['master_names' . $index] = $value;

  ----- Original Message ----- 
  From: Peter Sawczynec 
  To: 'Org, Talk at Nyphp.' 
  Sent: Monday, October 02, 2006 3:04 PM
  Subject: [nycphp-talk] Array Transformation Assistance.

  Go ahead chuckle it up. But, yes, I need this one little one. 
  I begin with a numerically indexed array of elements (could be any length):

  $master_names  = array("Joe", "Sam", "Tom" ... )

  I need to rename all the array elements as to make a matching consistent associative array.
  And... the keys in the associative array must be derived from combining the name of the array 
  (in this example 'master_names') with the correct former index value appended on the end of 
  each new key:

  $master_names = array('master_names0'=>"Joe", 'master_names1'=>"Sam, 'master_names2'=>"Tom" ... ) 





  Yes, that is it.

  Warmest regards, 

  Peter Sawczynec 
  Technology Director 
  _Design & Interface 
  _Database Management 
  ps at 


  New York PHP Community Talk Mailing List

  NYPHPCon 2006 Presentations Online

  Show Your Participation in New York PHP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the talk mailing list