Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9162423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:12:32+00:00 2026-06-17T14:12:32+00:00

No idea why this no longer array and no comma between {},{} foreach ($query->result_array()

  • 0

No idea why this no longer array and no comma between {},{}

foreach ($query->result_array() as $row) {
    header("Content-type: application/json");
    echo (json_encode($row,JSON_PRETTY_PRINT));
}

And how to alert json data in jquery?
Before this I use for loop in js to loop it but for some reason I have to loop in server side now.

Edited

//because i want to replace $row['url'] to get_thumb();    
foreach($query->result_array() as $row){
        $row['url'] = $this->vz_image->get_thumb($row['url'],'n');
        header("Content-type: application/json");
    echo (json_encode($row,JSON_PRETTY_PRINT));
    }

Then I got this result, but I have no idea how to alert this json data in jquery. Any help?

{
"id": "44",
"url": "assets\/img\/uploaded_photos\/thumbs\/1358786330_n.jpg",
"created_time": "1358786330",
"photo_id": "170",
"tag_id": "44",
"name": "Lan Yao Yeng",
"num_photo": "3"
}{
"id": "44",
"url": "assets\/img\/uploaded_photos\/thumbs\/1358711532_n.jpg",
"created_time": "1358711532",
"photo_id": "169",
"tag_id": "44",
"name": "Lan Yao Yeng",
"num_photo": "3"
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:12:34+00:00Added an answer on June 17, 2026 at 2:12 pm

    If you want to pass the entire array to the client, just encode the array itself, not each elements.

    function map($row){
        if (isset($row['url']))
            $row['url'] = $this->vz_image->get_thumb($row['url'],'n');
        return $row;
    }
    
    header("Content-type: application/json");
    echo json_encode(array_map("map", $query->result_array()),JSON_PRETTY_PRINT);
    

    If you use this in a class, you may have to change array_map("map", $query->result_array()) to array_map(array($this, "map"), $query->result_array()).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using GWT 2.0.3 with ext in my application.This project is no longer
Any idea why this code: extern C __declspec(dllexport) void Transform(double x[], double y[], int
Any idea why this wont print the errors? // Validate the email if (preg_match($regex,
Any idea why this is popping up :( ? You have an error in
The idea behind this small project of mine is to have an user enter
Any idea why this won't work? I m getting tags a user has set
So I have this idea for a RubyGem that I think would be an
I have no idea why this is happening. The error I get is the
I have no idea if this question fit to SO, but if it doesn't
I have no idea if this is possible, but if it is, what would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.