• 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-fopen: failed to open stream: Permission denied

Can't find vendor/autoload.php for Ratchet

How do I do HTTP basic authentication using Guzzle?

How to submit the custom form data in database in WordPress without plugin using ajax?

The "client_reference_id" argument is not passed

how to get value from array in laravel

Refresh specific HTML content that retrieves data from MySQL

Inserting Country Selection into MySQL PHP [duplicate]

Live search query using JS and PHP for QA forum

how do i retrieve and display the alt text of an image in wordpress?

How do I refresh a DIV content?

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

About Contact Privacy policy Terms and conditions