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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:56:46+00:00 2026-05-30T04:56:46+00:00

Okay, so I have some code that worked fine in PHP4 but since upgrading

  • 0

Okay, so I have some code that worked fine in PHP4 but since upgrading to PHP5 it does not produce the results I want.

This is some code I have that displays some news posts in a nice 3-column format. It checks where the news post shall go and adds it to the corresponding array. Then it prints out the array.

Assume $data is an array containing news post content such as title, date and content.

// Add to columns.
for($i=0; $i<sizeof($data); $i++) {
    // Convert Date Format.
    $old_date = $data[$i]['post_date'];
    $middle = strtotime($old_date);
    $new_date = date('F d, Y', $middle);

    // Calculate amount of text to display.
    if(strlen($nh->getContents($data[$i]['post_content'])) > 100) {
        $post_content = $nh->getSnippet($data[$i]['post_content'], 500, TRUE);
        $post_content .= "...<br /><br /><a href=\"showNewsPost.php?post_id={$data[$i]['post_id']}\">Read more...</a>";
    } else $post_content = $nh->getContents($data[$i]['post_content']);

    // Setup content variable.
    $content = "
        <div class=\"content post\">
            <h1 class=\"title\"><a href=\"showNewsPost.php?post_id={$data[$i]['post_id']}\">{$data[$i]['post_title']}</a></h1>
            <h2 class=\"subtitle\">Posted on {$new_date}</h2>
            {$post_content}
        </div>
    ";

    // Add to appropriate column array.
    if(in_array($i, $leftIDs)) $left[] = $content;
    else if(in_array($i, $midIDs)) $mid[] = $content;
    else if(in_array($i, $rightIDs)) $right[] = $content;
}

The problem is where I have the $content variable and add it to an array stack. For some reason it is not adding it. When dumping $content it displays the news contents–so the data is being fetched properly from the $data array.

Printing out the $left, $mid, and $right arrays returns empty arrays. I’ve checked if the if-statements at the bottom were returning true–and they were. So why is my data not being added?

EDIT: The entirety of my code can be found here

P.S.: The reason for the arrays xxID is to figure out in which column the current news post will go. Then I just print everything out so that everything is displayed nicely.

Old: old

New: new

UPDATE: The lines that add the closing </div> to the end of the array: $leftWrapper = sizeof($left) - 1; $left[$leftWrapper] = '</div>'; was overwriting the content that was added to array… odd because it worked in PHP4…. What a silly reason for not working. Thanks everyone for your input.

  • 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-30T04:56:48+00:00Added an answer on May 30, 2026 at 4:56 am

    My bet is you are a victim of http://php.net/manual/en/ini.core.php#ini.register-globals being defaulted to off in PHP5, as it should be since it can be security risk leaving them on. I would verify that, if that is true the solution can be complicated or easy, depending if you want security or not. In order to verify, you will need to either post a bit more code, or test on your server.

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

Sidebar

Related Questions

Okay I have updated my code a little, but I am still not exactly
For Google Maps V3, I have some code that created a marker when a
I have a problem with some excel code that I am having trouble getting
Okay so you have and array A[]... that is passed to you in some
I have some Python code that works correctly when I use python.exe to run
Okay I have seen some very similar questions here but none seem to be
I am using python 2.7, I have some code that looks like this: task1()
okay, so i have a text file with example content below line1with some random
Okay I have a large CRUD app that uses tabs with Forms embedded in
Okay I have updated my code quite a bit. I am getting a new

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.