note 86190 added to function.array-values

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
$array=array( 'value1'=>'value',
		    'array1'=> array( 'subItem1'=>'subItem1',	
	  				   'subItem2'=>'subItem2' ),
		    'array2'=> array( 'subItem1'=>'subItem1' ));
			
$newArray=array();
array_flatten($array,$newArray);
print_r( $newArray );

//Output
//Array
//(
//    [value1] => value
//    [array1|subItem1] => subItem1
//    [array1|subItem2] => subItem2
//    [array2|subItem1] => subItem1
//)

// recursively reduces deep arrays to single-dimensional arrays
function array_flatten($array, &$newArray = Array() ,$prefix='',$delimiter='|') {
  foreach ($array as $key => $child) {
	if (is_array($child)) {
	  $newPrefix = $prefix.$key.$delimiter;
	  $newArray =& array_flatten($child, $newArray ,$newPrefix, $delimiter);
	} else {
	  $newArray[$prefix.$key] = $child;
	}
  }
  return $newArray;
}
----
Server IP: 64.71.164.2
Probable Submitter: 84.181.141.82
----
Manual Page -- http://www.php.net/manual/en/function.array-values.php
Edit        -- https://master.php.net/note/edit/86190
Del: integrated  -- https://master.php.net/note/delete/86190/integrated
Del: useless     -- https://master.php.net/note/delete/86190/useless
Del: bad code    -- https://master.php.net/note/delete/86190/bad+code
Del: spam        -- https://master.php.net/note/delete/86190/spam
Del: non-english -- https://master.php.net/note/delete/86190/non-english
Del: in docs     -- https://master.php.net/note/delete/86190/in+docs
Del: other reasons-- https://master.php.net/note/delete/86190
Reject      -- https://master.php.net/note/reject/86190
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.