Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6131

Re: in_array performance in unsorted vs sorted array

From William Gill <noreply@domain.invalid>
Newsgroups comp.lang.php
Subject Re: in_array performance in unsorted vs sorted array
Date 2012-05-23 10:57 -0400
Organization A noiseless patient Spider
Message-ID <jpits7$dq8$1@dont-email.me> (permalink)
References <jphvj0$acu$1@dont-email.me> <jpikfl$kae$1@dont-email.me>

Show all headers | View raw


On 5/23/2012 8:16 AM, Jerry Stuckle wrote:
>
> Arrays in PHP are associative; their keys are handled as hash values. So
> I suspect it makes no difference on whether the array is sorted or not.
>
OK, That seems to be in sync with what I'm (not) finding in Google.

> Also, what's wrong with foreach() write()? That's how you get arrays
> back into a file. Ensure you lock the file so that you don't have two
> scripts running against it at the same time.
>
Nothing.  I just wanted to be sure I wasn't unaware of something better, 
like a function inverse to file().  Probably looking at less then 100k 
records at any time so I guess performance won't be a problem.

> But it sounds like you should be using a database. That would solve a
> lot of your problems.
>
Yes it does, and that's where this is heading.  Right now it is just 
summarizing some information, but eventually this will become a 
pre-processor for a db.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

in_array performance in unsorted vs sorted array William Gill <noreply@domain.invalid> - 2012-05-23 02:20 -0400
  Re: in_array performance in unsorted vs sorted array Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-23 08:16 -0400
    Re: in_array performance in unsorted vs sorted array William Gill <noreply@domain.invalid> - 2012-05-23 10:57 -0400
      Re: in_array performance in unsorted vs sorted array William Gill <noreply@domain.invalid> - 2012-05-23 11:01 -0400
    Re: in_array performance in unsorted vs sorted array Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2012-05-24 22:20 +0200
  Re: in_array performance in unsorted vs sorted array Captain Paralytic <paul_lautman@yahoo.com> - 2012-05-23 02:36 -0700

csiph-web