note 116414 deleted from ref.array by salathe

From: Date: Fri, 02 Jan 2015 11:32:45 +0000
Subject: note 116414 deleted from ref.array by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201332@lists.php.net to get a copy of this message
Note Submitter: elhan dot isaev at gmail dot com ---- /** * Replace Array keys * @param array $arr * @param mixed $old_keys * @param mixed $new_keys * @return Array * @author Elkhan I. Isaev <elhan.isaev@gmail.com>, Andrey Petrusev <laendyl@gmail.com> */ function array_key_replace (array $arr, $old_keys, $new_keys ) { return ! empty ( $arr ) ? array_combine( str_replace ( $old_keys, $new_keys, array_keys($arr) ), array_values($arr) ) : $arr; } /** example **/ $arr = array( 'one' => 'asdas', 'six' => array(1,3,array(4,2,3)), 'five' => 5, ); print_r(array_key_replace($arr, 'six', 'eleven'));

« previous php.notes (#201332) next »