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 3233096
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:14:15+00:00 2026-05-17T17:14:15+00:00

I have been looking around for PHP tutorials and I found a very detailed

  • 0

I have been looking around for PHP tutorials and I found a very detailed one that have been useful to me.

But now, I have a question. The results showed by the API are stored into a $results array. This is the code (for instance):

$fetch = mysql_fetch_row($go);
$return = Array($fetch[0],$fetch[1]);    
$results = Array(  
    'news' => Array (  
        'id'    => $return[0],  
        'title' => $return[1]  
    )); 

My question is.. I want to display the last 10 news.. how do I do this? On normal PHP / mySQL it can be done as:

    while($var = mysql_fetch_array($table)) {
    echo "do something"
 }

How can I make it so the $results can print multiple results?

I have tried like:

while($var = mysql_fetch_array($table)) {
    $results = Array(  
        'news' => Array (  
            'id'    => $return[0],  
            'title' => $return[1]  
        )); 
 }

But this only shows me one result. If I change the $results .= Array(…) it gives error.

What can I do?

Thanks!

Edit

My function to read it doesn’t read when I put it the suggested way:

function write(XMLWriter $xml, $data){
                            foreach($data as $key => $value){
                                    if(is_array($value)){
                                            $xml->startElement($key);
                                            write($xml, $value);
                                            $xml->endElement();
                                            continue;
                                    }
                                    $xml->writeElement($key, $value);
                            }
                    }
                    write($xml, $results);
  • 1 1 Answer
  • 1 View
  • 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-05-17T17:14:16+00:00Added an answer on May 17, 2026 at 5:14 pm
    $results[] = Array(  
            'news' => Array (  
                'id'    => $return[0],  
                'title' => $return[1]  
            )); 
    

    That should do it.

    If you are familiar with arrays, this is the equivalent of an array_push();

    array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed. Has the same effect as:

    <?php
    $array[] = $var;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking around ocn Google and Stackoverflow but haven't found what I
Hi StackOverflow friends. Running Drupal 6.22 php 5.3 I have been looking around now
I've been looking around the internet and haven't found out how, but have found
I've been looking around for a similar question, but I couldn't find one. I'm
I have been looking around for a visualization framework that would aid graph visualization
I have been looking around on the web and found some articles about the
I have been looking around and even found a couple of related answers and
I have been looking around the web for this but cannot really find a
I have been looking around for awhile now and I can't seem to find
I have been looking around for a regex expression that will spit out just

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.