• 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

Laravel Route issues with Route order in web.php

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

backup files to google drive using PHP

Check for PDO Results, If None Display Message, If Yes then Loop Through

How to disable only_full_group_by option in Laravel

php 7 php.ini upload_max_filesize not working

stay with the last 15 elements of an array [duplicate]

PHP Include for HTML?

Laravel csrf token mismatch for ajax POST Request

PHP/HTML: Creating A SubMenu

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Symfony/Form add attribute based on the data

How to add automatically collapse/expand in content wordpress (single.php)?

How to override header set in Apache config with more specific header in a virtual host

Laravel phpunit test failing authorization

About Contact Privacy policy Terms and conditions