Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add to json object php

<?php
$arr = '[
   {
      "id":1,
      "name":"Charlie"
   },
   {
      "id":2,
      "name":"Brown"
   },
   {
      "id":3,
      "name":"Subitem",
      "children":[
         {
            "id":4,
            "name":"Alfa"
         },
         {
            "id":5,
            "name":"Bravo"
         }
      ]
   },
   {
      "id":8,
      "name":"James"
   }
]';
$arr = json_decode($arr, TRUE);
$arr[] = ['id' => '9999', 'name' => 'Name'];
$json = json_encode($arr);

echo '<pre>';
print_r($json);
echo '</pre>';
Comment

PREVIOUS NEXT
Code Example
Php :: regex php password 
Php :: laravel run migration specific file 
Php :: Fatal error: Allowed memory size of 1610612736 bytes exhausted 
Php :: image store short method in laravel 
Php :: difference entre deux date php 
Php :: wordpress add_submenu_page 
Php :: php select option 
Php :: delete mysql php 
Php :: upload file in php 
Php :: get ip address in laravel 
Php :: php typecast to int 
Php :: phpexcel set data type string 
Php :: wordpress change language of specific text php 
Php :: ajax get request in laravel 
Php :: how to get current location latitude and longitude in php 
Php :: mysql secure 
Php :: convert timestamp to date php 
Php :: how to get parameter from url in laravel blade 
Php :: <a href="<?php echo base_url(); ?"somelink</a 
Php :: create livewire component 
Php :: laravel log build custom channel 
Php :: unable to open file error in php 
Php :: how to remove duplicate values from an array in php 
Php :: remove item in an array php 
Php :: php find first occurrence in string 
Php :: date to string php 
Php :: tinyinteger laravel +size 
Php :: search string inside array of objects php 
Php :: Woocommerce - Adding a Custom Endpoint 
Php :: php echo sql result 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =