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

  • Home
  • SEARCH
  • 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 4063260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:42:11+00:00 2026-05-20T15:42:11+00:00

I made a PHP app which was taking about ~0.0070sec for execution. Now, I

  • 0

I made a PHP app which was taking about ~0.0070sec for execution. Now, I added a hashtable array with about 2000 values. Suddenly the time for execution has gone up to ~0.0700 secs. Almost 10 times the previous value.

I tried commenting out the part where I was searching inside the hashtable array (but array was still left defined). Still, the execution time remains about ~0.0500secs.

Array is something like:

$subjectinfo = array(
        'TPT753' => 'Industrial Training',
        'TPT801' => 'High Polymeric Engineering',
        'TPT802' => 'Corrosion Engineering',
        'TPT803' => 'Decorative ,Industrial And High Performance Coatings',
        'TPT851' => 'Project');

Is there any way to optimize this part?

I cannot use Database as I am running this app on Google app engine which is still not supporting JDO database for php.

Some more code from the app:

function getsubjectinfo($name)
    {
        $subjectinfo = array(
        'TPT753' => 'Industrial Training',
        'TPT801' => 'High Polymeric Engineering',
        'TPT802' => 'Corrosion Engineering',
        'TPT803' => 'Decorative ,Industrial And High Performance Coatings',
        'TPT851' => 'Project');

    $name = str_replace("-", "", $name);
    $name = str_replace(" ", "", $name);
    if (isset($subjectinfo["$name"]))
        return "(".$subjectinfo["$name"].")";
    else
        return "";
   }

Then I am using the following statement 2-3 times in the app:

echo $key." ".$this->getsubjectinfo($key)
  • 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-20T15:42:11+00:00Added an answer on May 20, 2026 at 3:42 pm
    function getsubjectinfo($name)
    {
        $subjectinfo = array(
        'TPT753' => 'Industrial Training',
        'TPT801' => 'High Polymeric Engineering',
        'TPT802' => 'Corrosion Engineering',
        'TPT803' => 'Decorative ,Industrial And High Performance Coatings',
        'TPT851' => 'Project');
    // ..
    }
    

    This way the array is created everytime you call the function. Consider using a static variable here

    function getsubjectinfo($name)
    {
        static $subjectinfo = array(
        'TPT753' => 'Industrial Training',
        'TPT801' => 'High Polymeric Engineering',
        'TPT802' => 'Corrosion Engineering',
        'TPT803' => 'Decorative ,Industrial And High Performance Coatings',
        'TPT851' => 'Project');
    // ..
    }
    

    And as a sidenote: You can also use a SQLite-Database 🙂

    Update: An OOP approach

    class MyClass {
        public static $subjectnames = array(
          'TPT753' => 'Industrial Training',
          'TPT801' => 'High Polymeric Engineering',
          'TPT802' => 'Corrosion Engineering',
          'TPT803' => 'Decorative ,Industrial And High Performance Coatings',
          'TPT851' => 'Project');
    
        public function getsubjectinfo($name) {
            $name = str_replace("-", "", $name);
            $name = str_replace(" ", "", $name);
            if (isset(self::$subjectnames["$name"]))
                return "(".self::$subjectnames["$name"].")";
            else
                return "";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.