Search
 
SCRIPT & CODE EXAMPLE
 

PHP

replace key name in associative array

function change_key( $array, $old_key, $new_key ) {

    if( ! array_key_exists( $old_key, $array ) )
        return $array;

    $keys = array_keys( $array );
    $keys[ array_search( $old_key, $keys ) ] = $new_key;

    return array_combine( $keys, $array );
}
Comment

PREVIOUS NEXT
Code Example
Php :: Argument 1 passed to IlluminateDatabaseGrammar::parameterize() 
Php :: get pages with tempalte wp 
Php :: javascript,php error 
Php :: how to export and import database in phpmyadmin 
Php :: Using Cookie Authentication 
Php :: updateorinsert laravel for large data 
Php :: php if 2 files in dir unlink the olderst 
Php :: yii relations 
Php :: wp woocommerce change product tags to checbox 
Php :: laravel find user by id 
Php :: how to use php in laravel blade 
Php :: PHP code to redirect a user from a page to an alternate destination 
Php :: apache/2.4.53 (win64) openssl/1.1.1n php/8.1.5 server at localhost port 80 
Php :: thems 
Php :: php header x-powered-by 
Php :: php check if string startswith 
Php :: laravel view not created using foreign keys 
Php :: set php version in php.ini 
Php :: how to restrict user to some pages using php 
Php :: buddypress groups dropdown 
Php :: laravel Error: Unsupported operand types: IlluminateDatabaseEloquentCollection - int 
Php :: laravel create pivot migration 
Php :: automatice prevent default the form in php 
Php :: wordrpess debugg is off but still showing 
Php :: encode string for csv 
Php :: how to convert php code to a string 
Php :: shopware php get cookie 
Php :: laravel Why using additive paramerer in Resource collection raised error 
Php :: how use same method in another class in laravel 
Php :: ftp is uploading file but 0kb file size or data 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =