• 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

PHP rotate matrix counter-clockwise

Not able to access model in the controller mautic

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

hidden INPUT value not available in $_POST

Get sum of arrays inside array

Add customer email and phone in "Order" column to admin orders list on Woocommerce

CodeIgniter 3 is generating a session file on each request, why?

file_put_content...fail to open stream:Permission denied in Laravel 5

PHP how to detect if running on arm64 cpu?

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

How to install PHP composer inside a docker container

Can I use a WooCommerce function without any WooCommerce page?

Doctrine 2 mapping referencing unique key

Testing subscription renewals on Stripe

Converting alphabet letter to alphabet position in PHP [duplicate]

About Contact Privacy policy Terms and conditions