• 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

Getting values for an enum?

generating a random code in php?

Add New Parameter to Existing URL using htaccess

PHP DOTENV unable to load env vars

WordPress - Dynamically add user ID to the end of a URL

Sentry on Symfony: how to exclude `NotFoundHttpException`

How to add a heading in between checkout fields of WooCommerce

Auto increment id JSON

Laravel Delete and Update

add_action() function in wordpress not working [duplicate]

get folder directory from input type file - PHP

PHP Print to Network Printer

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

MOODLE: What does it mean to aggregate h5p assets?

The sum of the user's points

About Contact Privacy policy Terms and conditions