• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Need to display only array value in JSON output

phpjson


PHP Snippet 1:

$rows = array();
foreach ($user_details as $row) {
  $rows[] = array_values((array)$row);
}

echo json_encode(array('aaData'=> $rows));

PHP Snippet 2:

{"aaData": [
    ["31","Elankeeran","[email protected]","0","1234"],
    ["33","Elan","[email protected]","1",""]
]}

PHP Snippet 3:

echo '{"aaData":'.json_encode(array_values($user_details)).'}';

PHP Snippet 4:

obj.aaData[0].name;
// Elankeeran

obj.aaData[0].email;
// [email protected]

Related Snippets

add uri parameter to Route name in laravel

CodeIgniter 4: Like and Dislike Functionality

Use same method for inertia response and json response Laravel Jetstream

api response laravel doesn't show

how to see if database exists with PDO [duplicate]

Artisan, creating tables in database

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

Reload parent page after submit in iframe

Sum column values from multiple arrays

Render the content of default_filter.php in Joomla front-end

Search for array row with specific column value and return another value from qualifying row

Add a custom text for a particular product on specific email notification in Woocommerce

Show only featured products in Woocommerce shop page

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

Results page in other window

About Contact Privacy policy Terms and conditions