• 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

Remove categories with all childs derived from parent category

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

add " ? " in url via htaccess RewriteRule

(Cache::lock()) -> get() -- Under what conditions does it return false?

enable Apache http Authorization header

Transpose csv file data [duplicate]

Open a popup box after receiving result from ajax

CONCAT columns with Laravel 5 eloquent

Statement that checks whether a URL contains a particular path?

How can I get new CSRF token in LARAVEL by using ajax

Laravel/docker-compose/redis - Class 'Redis' not found

How do I do HTTP basic authentication using Guzzle?

Dropdown with current value from Mysql

Manage independently the decimal number of the price of each product [duplicate]

Php - Sum up the numbers in an array one by one

About Contact Privacy policy Terms and conditions