- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP Pushing values into an associative array?
To push values into an associative array, use the brackets  . At first create an associative array −
$details= array ( 'id' => '101', 'name' => 'John Smith', 'countryName' => 'US' );
The PHP code is as follows to insert values −
<!DOCTYPE html> <html> <body> <?php $details= array ( 'id' => '101', 'name' => 'John Smith', 'countryName' => 'US' ); $all_details['studentDetails'] = $details; print_r($all_details); ?> </body> </html>
Array ( [studentDetails] => Array (  => Array ( [id] => 101 [name] => John Smith [countryName] => US ) ) )
- PHP Associative Array
- Pushing values into array with multi field set to TRUE?
- PHP array_push() to create an associative array?
- Convert an object to associative array in PHP
- How to access an associative array by integer index in PHP?
- Remove duplicated elements of associative array in PHP
- Merging duplicate values into multi-dimensional array in PHP
- How to build dynamic associative array from simple array in php?
- PHP program to split a given comma delimited string into an array of values
- How to get numeric index of associative array in PHP?
- Associative Arrays in PHP
- PHP program to add item at the beginning of associative array