note 89902 deleted from function.define by cmb
| From: | cmb@php.net | Date: | Sun, 06 Oct 2019 07:54:22 +0000 |
| Subject: | note 89902 deleted from function.define by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212481@lists.php.net to get a copy of this message | ||
Note Submitter: Aldonio
----
This code will define every key of an array, and if its a multidimentional array it will define it
as parent_child1_child2_etc.
<?php
function define_array( $array, $keys = NULL )
{
foreach( $array as $key => $value )
{
$keyname = ($keys ? $keys . "_" : "") . $key;
if( is_array( $array[$key] ) )
define_array( $array[$key], $keyname );
else
define( $keyname, $value );
}
}
?>