• 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

Array to string conversion

GuzzleHttp Hangs When Using Localhost

Get all WooCommerce products within own plugin

How to average columns of data from multiple, flat arrays?

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

Add record for each array elements if missing in table

How do I pass the dynamic output of a php variable or php function to a CSS variable?

(Cache::lock()) -> get() -- Under what conditions does it return false?

Creating a config file in PHP

*** 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

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

Change the alert text on add to cart action without selected variation in Woocommerce

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

How to send parameters in soap request in php in __soapcall() function

Two buttons one form

About Contact Privacy policy Terms and conditions