• 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 to insert data into select2 search input after scan using qrcode

Wordpress how to get the post thumbnail inside a figure tag

WordPress - Dynamically add user ID to the end of a URL

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

How to implement placeholder in a php file for moodle plugin?

Laravel Factory not calling callback 'afterCreating'

How to retrieve Active Directory group policy maximum password age using LDAP

Check If array is null or not in php

yii2 and mssql insert varbinary into model

Laravel database insert with combining array and string

Composer fails with kylekatarnls/update-helper on new homestead

How to redirect to another page after n seconds in wordpress without using javascript?

PHP how to detect if running on arm64 cpu?

how to sort by a custom appended relation to model

Fatal error: [] operator not supported for strings

About Contact Privacy policy Terms and conditions