• 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

How can I easily switch between PHP versions on Mac OSX?

PHP mail sending empty mails

CSS file not imported in laravel blade view

Split comma separated value from table column into rows using mysql?

PhP how to calculate moments with variables rows

Wordpress 'post_type_link' hides permalink

onKeyUp event calculation not working on the following rows from php generated forms except the first one

MongoDB Duplicate Documents even after adding unique key

Laravel Delete and Update

AJAX call fails with SyntaxError: Unexpected end of JSON input

Composer Warning: openssl extension is missing. How to enable in WAMP

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

How to execute sql code based on fetch array

Transform array, set each array element with parent key php

Laravel update hasMany relationship using saveMany

About Contact Privacy policy Terms and conditions