• 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

ldap is missing from system when installing adldap2 in laravel

How do I do HTTP basic authentication using Guzzle?

Required field only if another field has a value, must be empty otherwise

Laravel 5 controller sending JSON integer as string

How can i hide dt if dd got empty value

Upgrade PHP on AWS Linux

Laravel Schedule not sending email

SilverStripe unable to populate multiple member Childs

Sum array values of a column within each column of an array with 3 levels

Insert a DIV after the 6th product only once in WooCommerce category archives

Unable to guess the mime type as no guessers are available Laravel 5.2

Which is faster php date functions or carbon?

How to send image,audio or video through the WhatsApp API - PHP

How Can I Do LIMIT 1, 2 In WP_Query

Update Order custom Field value with WooCommerce REST API

About Contact Privacy policy Terms and conditions