• 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

Error converting docx to pdf using Unoconv

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

Add Class in html Dynamically in PHP

Laravel You requested 1 items, but there are only 0 items available

PHP: set a (deep) array key from an array [closed]

ORA-12546: TNS:permission denied error connection to remote oracle server

PhP how to calculate moments with variables rows

How to MODIFY a Google Docs document via API using search-and-replace?

how to loop through json response data using ajax jquery?

oauth-private.key does not exist or is not readable

How to prevent phpmailer sending embedded image as an attachment on Gmail?

PHP and WebView - Cookie doesn't are the same

Unit (real unit test) of test laravel relationship

Pass an image through AJAX [duplicate]

MongoDB Duplicate Documents even after adding unique key

About Contact Privacy policy Terms and conditions