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


Groups > comp.lang.php > #11819

Re: searching an array

From David Robley <me@home.invalid>
Newsgroups comp.lang.php
Subject Re: searching an array
Followup-To comp.lang.php
Date 2013-11-18 21:57 +1030
Organization albasani.net
Message-ID <l6ctf3$sgr$1@news.albasani.net> (permalink)
References <1r19n2u8ujc0e$.kh04fdyfhu79$.dlg@40tude.net>

Followups directed to: comp.lang.php

Show all headers | View raw


richard wrote:

> I am now attempting to set up a display using a simple table.
> row 1 is headers.
> row 2 is for the main track title.
> row 3 is for the flipside.
> 
> http://mroldies.net/list/decade60.html
> 
> Many times the flipside was also charted.
> So I need to know what the corresponding number is for the flipside in
> order to show that information.
> 
> from the "manual" I am using this:
> 
> $flip=$six0[$track][1];
> 
> $flip2=array_search($flip,$six0);
> 
> if ($flip2=null){echo "does not exist";}
> 
> How do I properly code it so that when a match is not found?
> Neither null or "" seems to work.
> 
> $six0=array(
> 1 => array("The Theme From \"A Summer Place\"","Go-Go-Po-Go","Columbia
> 4-41490","Percy Faith","Max Steiner","21","1","1/11/1960","1"),
> 2 => array("Are You Lonesome To-Night?","I Gotta Know*","RCA Victor
> 47-7810","Elvis Presley","Roy Turk Lou
> Handman","16","1","11/14/1960","2"), 3 => array("It's Now Or Never","A
> Mess Of Blues*","RCA Victor 47-7777","Elvis Presley","Aaron Schroeder
> Wally Gold","20","1","7/18/1960","3")
> )

Other(s) have mentioned the confusion of = and ==.

Seeing you are quoting the "manual" you may wish to refer to it again and 
see what the return value of array_search is if a match is not found; it is 
neither null or "". It might also be useful to review the warning under the 
information on return values.

-- 
Cheers
David Robley

If I had anything witty to say, I wouldn't put it here.

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


Thread

searching an array richard <noreply@example.com> - 2013-11-17 22:37 -0500
  Re: searching an array Richard Yates <richard@yatesguitar.com> - 2013-11-17 20:57 -0800
    Re: searching an array richard <noreply@example.com> - 2013-11-18 00:28 -0500
  Re: searching an array David Robley <me@home.invalid> - 2013-11-18 21:57 +1030
    Re: searching an array Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-18 11:38 -0500
      Re: searching an array Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-18 18:24 +0000
  Re: searching an array Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-18 18:23 +0000

csiph-web