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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:24:58+00:00 2026-05-25T13:24:58+00:00

I am attempting to use a foreach to output the array below. I have

  • 0

I am attempting to use a foreach to output the array below. I have created this array via array_push() based on preg_match if/else.

Array (
    [0] => Array (
        [date] => 
        [clickurl] => some data
        [url] => some data
        [dispurl] => some Data...
        [title] => Transformers: Revenge of the Fallen : Reviews
        [abstract] => "Transformers: Revenge of the Fallen" is a horrible experience of unbearable length, briefly punctuated by three or four amusing moments.
    )

    [1] => Array (
        [date] => 
        [clickurl] => some data
        [url] => some data
        [dispurl] => some Data...
        [title] => Transformers : Reviews
        [abstract] => After a string of bad-to-mediocre films, director Michael Bay scores with blockbuster battling robots in "Transformers."
    )
)

When attempting to output the array:

foreach ($reviewArr as $review) {
    echo($review['clickurl']. '<br/><br/>');
}

The output is “A” which is the first letter of Array at the start of the array above. This is the same result as using $review[0];

When using:

foreach ($reviewArr as $review) {
    echo($review. '<br/><br/>');
}

the output is:

Array ( 
    [date] => 
    [clickurl] => some data 
    [url] => some data
    [dispurl] => some data... 
    [title] => Transformers : Reviews 
    [abstract] => After a string of bad-to-mediocre films, director Michael Bay scores with blockbuster battling robots in "Transformers." 
) 

I am not sure why this is happening. Any help will be greatly appreciated.

thanks!

UPDATE =

This is the original Array that I parse below to split into two different arrays.

Array
    (
[bossresponse] => Array
    (
        [responsecode] => 200
        [web] => Array
            (
                [start] => 0
                [count] => 14
                [totalresults] => 14
                [results] => Array
                    (
                        [0] => Array
                            (
                                [date] => 
                                [clickurl] => http://url.com/1
                                [url] => http://url.com/1
                                [dispurl] => http://url.com/1...
                                [title] => Title of Content 1
                                [abstract] => This is the summary, This is the summary,    This is the summary, ...
                            )

                        [1] => Array
                            (
                                [date] => 
                                [clickurl] => http://url.com/2
                                [url] => http://url.com/2
                                [dispurl] => http://url.com/2...
                                [title] => Title of Content 2
                                [abstract] => This is the summary, This is the summary,  This is the summary, ...
                            )
                    )

              )

       )

)

This is how I am setting the $reviewArr[].

foreach ($results['bossresponse']['web']['results'] as $key => $result) {
                $url = $result['clickurl'];
                $title = $result['title'];
                $abstract = $result['abstract'];
                $resultItem = print_r($results['bossresponse']['web']['results'][$key], true);
                if (preg_match ("/reviews/i", "$url")) {
                    array_push($reviewArr, "$resultItem");
                } else {
                    array_push($resultsArr, "$resultItem");
                }
            }

UPDATE #2 –

I see thanks to @fabio that I am simply setting a string with $resultItem above. How can I achieve creating a multidimensional array? How can I build this as an array – all of my attempts returned errors, or a string.

 Array
                    (
                        [0] => Array
                            (
                                [date] => 
                                [clickurl] => http://url.com/1
                                [url] => http://url.com/1
                                [dispurl] => http://url.com/1...
                                [title] => Title of Content 1
                                [abstract] => This is the summary, This is the summary,    This is the summary, ...
                            )

                        [1] => Array
                            (
                                [date] => 
                                [clickurl] => http://url.com/2
                                [url] => http://url.com/2
                                [dispurl] => http://url.com/2...
                                [title] => Title of Content 2
                                [abstract] => This is the summary, This is the summary,  This is the summary, ...
                            )
                    )
  • 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-05-25T13:24:59+00:00Added an answer on May 25, 2026 at 1:24 pm

    Change:

    foreach ($results['bossresponse']['web']['results'] as $key => $result) {
        $url = $result['clickurl'];
        $title = $result['title'];
        $abstract = $result['abstract'];
        $resultItem = print_r($results['bossresponse']['web']['results'][$key], true);
        if (preg_match ("/reviews/i", "$url")) {
            array_push($reviewArr, "$resultItem");
        } else {
            array_push($resultsArr, "$resultItem");
        }
    }
    

    to:

    foreach ($results['bossresponse']['web']['results'] as $key => $result) {
        if (preg_match ("/reviews/i", $result['clickurl'])) {
            $reviewArr[] = $result;
        } else {
            $resultsArr[] = $result;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to capture the output of fputcsv() in order to use gzwrite() to
I'm attempting to intercept and filter items out of a class set array, $this->_vars,
Ok, I am attempting to use this custom extension to perform an entity update.
This is the method I am attempting to use whilst trying to send a
I have an html dropdown box. Then I use an array to fill the
I am attempting to use a recursive function to search through a multidimensional array,
I am attempting to use reflection to determine which Properties of a Type have
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
In attempting to use the Performance Tools on an ASP.NET website I'm getting various

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.