• 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 fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Get sum of arrays inside array

Laravel Mix Uncaught ReferenceError: $ is not defined

Laravel MSSQL Server Connection not working

Explode not working properly with dash

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Parsing JSON File to array in PHP

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

MySQL default time format UTC or GMT?

Require a class from another class - php

Convert regular text to array using notepad++

Remove categories with all childs derived from parent category

How to validate tin and cst using PHP?

I want to display a sweetalert after the inserting of data in my database

Composer fails with kylekatarnls/update-helper on new homestead

About Contact Privacy policy Terms and conditions