• 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

Sort a multidimensional array by integer inside of a string value which is two levels down

PHP Get value from JSON [duplicate]

Make survey at laravel 5.4 and MySQL

What is the difference between client-side and server-side programming?

How to convert the int value to inch in PHP [closed]

Submitting a form with ajax in Wordpress

google content api for shopping

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Call to undefined function openssl_decrypt

How do I call a php file with axios?

How to upload mpdf file after generating to s3 bucket in php

Zig-zag scan an N x N array

Google Calendar API batch request PHP

PHP Include for HTML?

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

About Contact Privacy policy Terms and conditions