• 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

PHP Warning: Module already loaded in Unknown on line 0

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

PHP: Telegram Bot: Insert line break to text message

How do I refresh a DIV content?

Appending data to an anchor tag

PHP if in_array() how to get the key as well?

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

Modify microseconds of a PHP DateTime object

PHP - installing Xdebug on Mac with XAMPP (Unix File)

Populate Dynamic Dropdowns List in Codeigniter

Zig-zag scan an N x N array

PHPExcel export HTML table to xlsx

backup files to google drive using PHP

php 7 php.ini upload_max_filesize not working

About Contact Privacy policy Terms and conditions