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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:55:23+00:00 2026-05-26T20:55:23+00:00

I’ve been playing around with searching text in big lists and found that using

  • 0

I’ve been playing around with searching text in big lists and found that using a PHP array seems to be a quick way of doing it.

E.g. if you had loads of place names and associated postcodes you could read them into a PHP array like this:

$place[‘place name here’] = “postcode”;

Then to look up you just take the place you want to look up and plug it in to the array:

$postcode_sought = $place[‘place I want to look up’];

I thought I could speed this up using C++ but of course C++ does not allow (as far as I know) arrays with a string as the index.

The only way I can think to do it is to create vectors for the place and postcode and loop through the place vector looking for a match but the repeated string comparisons take forever as I’d expected. I also experimented with hashing the text but I still couldn’t get it anywhere near as fast as PHP.

I think PHP is written in C so my question is how does C manage to create this string index name functionality for PHP?
I’m not looking for the actual code or anything, it just seems to me that there must be some fundamental technique that is used for this and I was just wondering if there is anyone out there who could briefly explain it.

Thanks in advance.
C

  • 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-26T20:55:24+00:00Added an answer on May 26, 2026 at 8:55 pm

    I thought I could speed this up using C++ but of course C++ does not allow (as far as I know) arrays with a string as the index.

    It does, You can use std::map as an Associative array.

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

Sidebar

Related Questions

I've been playing around with Qt for a few hours now. I found that
I've been playing around with GEdit's syntax highlighting. I love the way that Visual
I've been playing around with creating an application using the S#arp Architecture . One
I've been playing around and searching a bit, but I can't figure this out.
I've been playing around with type deduction/printing using templates with code of the form:
I've been playing around with HPricot, but after a fair amount of searching, I've
I've been searching around for a solution to this but haven't really found one.
I have been playing around with a search control and i have noticed that
Been playing around with Joda timezones and found the following which seemed odd. I
i've been playing around with Attributes over web services, and i've seen that The

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.