• 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

Detect if PHP session exists

Add restriction to WooCommerce coupons by allowed user ID

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

PHP array stringify

retrieve data from database using session

Download & Save Zoom Recording in directory by PHP

Symfony/Form add attribute based on the data

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

Laravel Carbon throws error The format separator does not match

Is there a way to use Foundry Model for Authentification inside Functional Tests?

"There is no active transaction" when refreshing database in Laravel 8.0 test

How to create a cookie to store the timestamp of when a page is first loaded with php

Laravel Collections. Is there some kind of assertStructure method?

How can i call a function that executes an fpdf based on the choice of a form selector?

Laravel s3 upload file with metadata using pre-signed url

About Contact Privacy policy Terms and conditions