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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:21:00+00:00 2026-06-14T01:21:00+00:00

I have created a PHP script but while using it in my hosting server

  • 0

I have created a PHP script but while using it in my hosting server it show fatal error, then i have discovered that i need to compress this PHP code to make my script working.. Here is the code, any one can compress this code with the same output, i am a beginner in coding so can’t understand how to act this same output with minimized code and efforts so that server can easily execute this code. Thanks
The Code Need to be optimize:

$yar = 3;
while ($yar <= 9) {
    $ax = 31;
    while ($ax > 0) {
        $jaan = "$ax Jan 200$yar";
        $result = str_replace($jaan, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $feeb = "$ax Feb 200$yar";
        $result = str_replace($feeb, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $maar = "$ax Mar 200$yar";
        $result = str_replace($maar, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $appr = "$ax Apr 200$yar";
        $result = str_replace($appr, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $maay = "$ax May 200$yar";
        $result = str_replace($maay, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $juun = "$ax Jun 200$yar";
        $result = str_replace($juun, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $juul = "$ax Jul 200$yar";
        $result = str_replace($juul, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $auug = "$ax Aug 200$yar";
        $result = str_replace($auug, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $seep = "$ax Sep 200$yar";
        $result = str_replace($seep, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $occt = "$ax Oct 200$yar";
        $result = str_replace($occt, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $noov = "$ax Nov 200$yar";
        $result = str_replace($noov, " ", $result);
        $ax = $ax - 1;
    }
    $ax = 31;
    while ($ax > 0) {
        $deec = "$ax Dec 200$yar";
        $result = str_replace($deec, " ", $result);
    }
        $ax = $ax - 1;
    $yar++;
} //years start after 2010 to 2014
$yr = 10;
while ($yr <= 14) {
    $x = 31;
    while ($x > 0) {
        $jan = "$x Jan 20$yr";
        $result = str_replace($jan, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $feb = "$x Feb 20$yr";
        $result = str_replace($feb, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $mar = "$x Mar 20$yr";
        $result = str_replace($mar, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $apr = "$x Apr 20$yr";
        $result = str_replace($apr, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $may = "$x May 20$yr";
        $result = str_replace($may, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $jun = "$x Jun 20$yr";
        $result = str_replace($jun, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $jul = "$x Jul 20$yr";
        $result = str_replace($jul, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $aug = "$x Aug 20$yr";
        $result = str_replace($aug, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $sep = "$x Sep 20$yr";
        $result = str_replace($sep, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $oct = "$x Oct 20$yr";
        $result = str_replace($oct, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $nov = "$x Nov 20$yr";
        $result = str_replace($nov, " ", $result);
        $x = $x - 1;
    }
    $x = 31;
    while ($x > 0) {
        $dec = "$x Dec 20$yr";
        $result = str_replace($dec, " ", $result);
        $x = $x - 1;
    }
    $yr++;
}
  • 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-14T01:21:02+00:00Added an answer on June 14, 2026 at 1:21 am

    I’ll post the same code that I posted in your previous thread:

    Why go through such a long and odd process, when you can do something like this?

    <?php
        $yearStart = 2004;
        $yearEnd = 2012;
        $unixTime = strtotime($yearStart . "-01-01 00:00:00");
        $endUnixTime = strtotime($yearEnd . "-12-31 23:59:59");
        while ($unixTime < $endUnixTime) {
            echo date("d M Y", $unixTime) . PHP_EOL;
            $unixTime = strtotime("+1 day", $unixTime);
        }
    ?>
    

    Output:

    01 Jan 2004
    02 Jan 2004
    03 Jan 2004
    ...
    29 Dec 2012
    30 Dec 2012
    31 Dec 2012
    

    This also has the added bonus of not showing “31 Feb 2008” etc., as that date doesn’t even exist.

    Codepad example of the code (WARNING: long output!)

    Edit

    If you want to replace every date like this with a space, you can use this one-liner (replace every date with a space):

    $result = preg_replace("/([0-2][0-9]|3[0-1]) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{4}/", " ", $result);
    

    It will turn

    01 Jan 2004 blah blah 02 Jan 2004 and blah 03 Jan 2004 and who even cares about 31 Dec 2050? I know that I don’t.

    into

    blah blah and blah and who even cares about ? I know that I don’t.

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

Sidebar

Related Questions

I have created a dynamic list picker script using Jquery 1.3 and PHP that
I am using my admin panel login script where i have created a global.php
I have created a PHP script and I am lacking to extract the primary
I have a PHP script that creates other PHP files based on user input.
I have php script that creates a temporary watermark image for users that are
I have a PHP script that creates large complex tables. I am attempting to
I have a PHP script where I create a new process using proc_open().It executes
I hope that title makes sense.... Basically I created PHP script to take data
I have created a survey system using php and mysql. I have a table
I have a script on my site ('write-review.php') that takes an optional url parameter

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.