Array Search Not Working?

Array Search Not Working?

am 10.03.2010 15:52:30 von Alice Wei

--_14914717-18ad-482b-bd84-94bf8cdfa622_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Hi=2C

I have two arrays here that I have combined into a new array=2C as shown =
here:

$from =3D explode("-"=2C $from)=3B
$change =3D explode("-"=2C$change)=3B
$new_array =3D array_combine($from=2C$change)=3B

I then tried reading it from a file and do string matches=2C trying to find=
out the "key" using the array_search of the individual array elements. I s=
eem to have no such luck=2C even when I copied one of the elements after I =
do a print_r($new_array);

Here is the code=2C

foreach ($lines2 as $line_num =3D> $line2) {=20
$style_line_num =3D $line_num+3=3B

if(preg_match("/^style/"=2C$line2)) {
=20
if(preg_match("/inkscape:label/"=2C$lines2[$style_line_num]) ) {=
=20
$location =3D explode("=3D"=2C$lines2[$style_line_num])=3B
$location2 =3D substr($patient_location[1]=2C1=2C-6)=3B =20
=20
if(in_array($location2=2C $from)) { =20
$key=3D array_search($location2=2C$new_array)=3B //Find out th=
e position of the index in the array =20
echo "Key " . $key . "
"=3B //This only gives me a blank s=
pace after the word Key
=20
} =20

} //end preg_match inkscape =20
} //If preg_match style

I looked at the example from http://php.net/manual/en/function.array-search=
..php=2C and looks like what I am trying to do here is possible=2C and yet=
=2C why am I not getting a proper key return?

Thanks for your help.

Alice
=20
____________________________________________________________ _____
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/=

--_14914717-18ad-482b-bd84-94bf8cdfa622_--

Re: Array Search Not Working?

am 10.03.2010 17:09:54 von Shawn McKenzie

Alice Wei wrote:
> Hi,
>
> I have two arrays here that I have combined into a new array, as shown here:
>
> $from = explode("-", $from);
> $change = explode("-",$change);
> $new_array = array_combine($from,$change);
>
> I then tried reading it from a file and do string matches, trying to find out the "key" using the array_search of the individual array elements. I seem to have no such luck, even when I copied one of the elements after I do a print_r($new_array);
>
> Here is the code,
>
> foreach ($lines2 as $line_num => $line2) {
> $style_line_num = $line_num+3;
>
> if(preg_match("/^style/",$line2)) {
>
> if(preg_match("/inkscape:label/",$lines2[$style_line_num])) {
> $location = explode("=",$lines2[$style_line_num]);
> $location2 = substr($patient_location[1],1,-6);
>
> if(in_array($location2, $from)) {
> $key= array_search($location2,$new_array); //Find out the position of the index in the array
> echo "Key " . $key . "
"; //This only gives me a blank space after the word Key
>
> }
>
> } //end preg_match inkscape
> } //If preg_match style
>
> I looked at the example from http://php.net/manual/en/function.array-search.php, and looks like what I am trying to do here is possible, and yet, why am I not getting a proper key return?
>
> Thanks for your help.
>
> Alice
>
> ____________________________________________________________ _____
> Hotmail: Powerful Free email with security by Microsoft.
> http://clk.atdmt.com/GBL/go/201469230/direct/01/

It's not clear what you are doing, but here is the problem that you are
asking about. array_combine() builds an array using the values from
$from as the keys of the new array and the values from change as the
values of the new array.

So here, if $locations2 is a value in the $from array:
if(in_array($location2, $from)) {

But here you are searching the values of $new_array which are copies of
the values from $to.
$key= array_search($location2,$new_array);


--
Thanks!
-Shawn
http://www.spidean.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Array Search Not Working?

am 10.03.2010 17:21:26 von Alice Wei

--_1f296868-b3a6-450a-9cbb-554f2dd6ba29_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


> Date: Wed=2C 10 Mar 2010 10:09:54 -0600
> From: nospam@mckenzies.net
> To: ajwei@alumni.iu.edu
> CC: php-general@lists.php.net
> Subject: Re: Array Search Not Working?
>=20
> Alice Wei wrote:
> > Hi=2C
> >=20
> > I have two arrays here that I have combined into a new array=2C as sh=
own here:
> >=20
> > $from =3D explode("-"=2C $from)=3B
> > $change =3D explode("-"=2C$change)=3B
> > $new_array =3D array_combine($from=2C$change)=3B
> >=20
> > I then tried reading it from a file and do string matches=2C trying to =
find out the "key" using the array_search of the individual array elements.=
I seem to have no such luck=2C even when I copied one of the elements afte=
r I do a print_r($new_array);
> >=20
> > Here is the code=2C
> >=20
> > foreach ($lines2 as $line_num =3D> $line2) {=20
> > $style_line_num =3D $line_num+3=3B
> >=20
> > if(preg_match("/^style/"=2C$line2)) {
> > =20
> > if(preg_match("/inkscape:label/"=2C$lines2[$style_line_num]=
)) { =20
> > $location =3D explode("=3D"=2C$lines2[$style_line_num])=3B
> > $location2 =3D substr($patient_location[1]=2C1=2C-6)=3B =20
> > =20
> > if(in_array($location2=2C $from)) { =20
> > $key=3D array_search($location2=2C$new_array)=3B //Find ou=
t the position of the index in the array =20
> > echo "Key " . $key . "
"=3B //This only gives me a bla=
nk space after the word Key
> > =20
> > } =20
> >=20
> > } //end preg_match inkscape =20
> > } //If preg_match style
> >=20
> > I looked at the example from http://php.net/manual/en/function.array-se=
arch.php=2C and looks like what I am trying to do here is possible=2C and y=
et=2C why am I not getting a proper key return?
> >=20
> > Thanks for your help.
> >=20
> > Alice
> > =20
> > ____________________________________________________________ _____
> > Hotmail: Powerful Free email with security by Microsoft.
> > http://clk.atdmt.com/GBL/go/201469230/direct/01/
>=20
> It's not clear what you are doing=2C but here is the problem that you are
> asking about. array_combine() builds an array using the values from
> $from as the keys of the new array and the values from change as the
> values of the new array.
>=20
> So here=2C if $locations2 is a value in the $from array:
> if(in_array($location2=2C $from)) {
>=20
> But here you are searching the values of $new_array which are copies of
> the values from $to.
> $key=3D array_search($location2=2C$new_array)=3B
>=20
>=20
> --=20
> Thanks!
> -Shawn

Here is what I wanted to do:

$from =3D "Adair=2C OK-Alfalfa=2C OK-Atoka=2C OK-Beaver=2C OK-Beckham=2C OK=
-Blaine=2C OK-Bryan=2C OK-Caddo=2C OK-Canadian=2C OK-Carter=2C OK-Cherokee=
=2C OK-Choctaw=2C OK-Cimarron=2C OK-Cleveland=2C OK-Coal=2C OK-Comanche=2C =
OK-Cotton=2C OK-Craig=2C OK-Creek=2C OK-Custer=2C OK-Delaware=2C OK-Dewey=
=2C OK-Ellis=2C OK-Garfield=2C OK-Garvin=2C OK-Grady=2C OK-Grant=2C OK-Gree=
r=2C OK-Harmon=2C OK-Harper=2C OK-Haskell=2C OK-Hughes=2C OK-Jackson=2C OK-=
Jefferson=2C OK-Johnston=2C OK-Kay=2C OK-Kingfisher=2C OK-Kiowa=2C OK-Latim=
er=2C OK-Le Flore=2C OK-Lincoln=2C OK-Logan=2C OK-Love=2C OK-Major=2C OK-Ma=
rshall=2C OK-Mayes=2C OK-McClain=2C OK-McCurtain=2C OK-McIntosh=2C OK-Murra=
y=2C OK-Muskogee=2C OK-Noble=2C OK-Nowata=2C OK-Okfuskee=2C OK-Oklahoma=2C =
OK-Okmulgee=2C OK-Osage=2C OK-Ottawa=2C OK-Pawnee=2C OK-Payne=2C OK-Pittsbu=
rg=2C OK-Pontotoc=2C OK-Pottawatomie=2C OK-Pushmataha=2C OK-Roger Mills=2C =
OK-Rogers=2C OK-Seminole=2C OK-Sequoyah=2C OK-Stephens=2C OK-Texas=2C OK-Ti=
llman=2C OK-Tulsa=2C OK-Wagoner=2C OK-Washington=2C OK-Washita=2C OK-Woods=
=2C OK-Woodward=2C OK
"=3B
$state_colors=3D "#FFFFCC-#FFFFCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#=
FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCC CC-#FFCCCC-#FFC=
CCC-#FFCCCC-#FFCCCC-#FFCCCC-#FF9999-#FF9999-#FF9999-#FF9999- #FF9999-#FF9999=
-#FF9999-#FF9999-#FF9999-#FF9999-#FF9999-#FF9999-#FF9999-#FF 9999-#FF9999-#F=
F9999-#FF9999-#FF9999-#FF9999-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCF F-#0DCCFF-#0DCC=
FF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-# 0DCCFF-#0DCCFF-=
#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DC CFF-#0DCCFF-#0D=
CCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF -#0DCCFF-#0DCCF=
F-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF"=3B
$change=3D "207-158-189-220-134-74.9-174-75.1-38-125-173-215-390-39-141 -92.=
1-121-175-80.1-95.4-191-124-169-101-77-52-117-155-188-176-16 9-114-158-122-1=
41-107-43-122-181-223-53.7-41.5-131-112-144-147-48-249-141-1 01-155-81.4-158=
-92.3-16.3-105-153-186-108-69.2-146-103-53.4-225-140-136-80. 4-179-93.3-277-=
136-110-136-143-103-183-141";;

$from =3D explode("-"=2C $from)=3B
$state_colors=3D explode("-"=2C $state_colors)=3B
$change =3D explode("-"=2C$change)=3B

$new_array =3D array_combine($from=2C$change)=3B
print_r($new_array)=3B

Although array_combine does put the two arrays together=2C I cannot really =
"sort" with the array=2C because there is text and numeric in there. Plus=
=2C array_search seems to be only able to search through one dimension. I w=
ould really like to know how I can first sort through the $new_array accord=
ing to the "numeric" and NOT the "text".=20

I then would like to use the "index" after the sort to use as the "key" to =
find out what "color" I am supposed to use according to the position.=20

Is this possible? And=2C are there some directions on where I can start thi=
s?

Thanks for your help.

Alice
=20
____________________________________________________________ _____
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/201469229/direct/01/=

--_1f296868-b3a6-450a-9cbb-554f2dd6ba29_--

RE: Array Search Not Working?

am 10.03.2010 17:43:47 von Alice Wei

--_63e038d0-1634-4a4e-a728-3267609d69fe_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


From: ajwei@alumni.iu.edu
To: nospam@mckenzies.net
CC: php-general@lists.php.net
Subject: RE: Array Search Not Working?
Date: Wed=2C 10 Mar 2010 11:21:26 -0500








> Date: Wed=2C 10 Mar 2010 10:09:54 -0600
> From: nospam@mckenzies.net
> To: ajwei@alumni.iu.edu
> CC: php-general@lists.php.net
> Subject: Re: Array Search Not Working?
>=20
> Alice Wei wrote:
> > Hi=2C
> >=20
> > I have two arrays here that I have combined into a new array=2C as sh=
own here:
> >=20
> > $from =3D explode("-"=2C $from)=3B
> > $change =3D explode("-"=2C$change)=3B
> > $new_array =3D array_combine($from=2C$change)=3B
> >=20
> > I then tried reading it from a file and do string matches=2C trying to =
find out the "key" using the array_search of the individual array elements.=
I seem to have no such luck=2C even when I copied one of the elements afte=
r I do a print_r($new_array);
> >=20
> > Here is the code=2C
> >=20
> > foreach ($lines2 as $line_num =3D> $line2) {=20
> > $style_line_num =3D $line_num+3=3B
> >=20
> > if(preg_match("/^style/"=2C$line2)) {
> > =20
> > if(preg_match("/inkscape:label/"=2C$lines2[$style_line_num]=
)) { =20
> > $location =3D explode("=3D"=2C$lines2[$style_line_num])=3B
> > $location2 =3D substr($patient_location[1]=2C1=2C-6)=3B =20
> > =20
> > if(in_array($location2=2C $from)) { =20
> > $key=3D array_search($location2=2C$new_array)=3B //Find ou=
t the position of the index in the array =20
> > echo "Key " . $key . "
"=3B //This only gives me a bla=
nk space after the word Key
> > =20
> > } =20
> >=20
> > } //end preg_match inkscape =20
> > } //If preg_match style
> >=20
> > I looked at the example from http://php.net/manual/en/function.array-se=
arch.php=2C and looks like what I am trying to do here is possible=2C and y=
et=2C why am I not getting a proper key return?
> >=20
> > Thanks for your help.
> >=20
> > Alice
> > =20
> > ____________________________________________________________ _____
> > Hotmail: Powerful Free email with security by Microsoft.
> > http://clk.atdmt.com/GBL/go/201469230/direct/01/
>=20
> It's not clear what you are doing=2C but here is the problem that you are
> asking about. array_combine() builds an array using the values from
> $from as the keys of the new array and the values from change as the
> values of the new array.
>=20
> So here=2C if $locations2 is a value in the $from array:
> if(in_array($location2=2C $from)) {
>=20
> But here you are searching the values of $new_array which are copies of
> the values from $to.
> $key=3D array_search($location2=2C$new_array)=3B
>=20
>=20
> --=20
> Thanks!
> -Shawn

Hi,

Looks like I have figured out how to get it to sort numerically after the p=
rint out =2C but still I cannot get it to do the array_search to find out t=
he index of the "element" in this "new_array".=20

Here is the code,

$from =3D "Adair=2C OK-Alfalfa=2C OK-Atoka=2C OK-Beaver=2C OK-Beckham=2C OK=
-Blaine=2C OK-Bryan=2C OK-Caddo=2C OK-Canadian=2C OK-Carter=2C OK-Cherokee=
=2C OK-Choctaw=2C OK-Cimarron=2C OK-Cleveland=2C OK-Coal=2C OK-Comanche=2C =
OK-Cotton=2C OK-Craig=2C OK-Creek=2C OK-Custer=2C OK-Delaware=2C OK-Dewey=
=2C OK-Ellis=2C OK-Garfield=2C OK-Garvin=2C OK-Grady=2C OK-Grant=2C OK-Gree=
r=2C OK-Harmon=2C OK-Harper=2C OK-Haskell=2C OK-Hughes=2C OK-Jackson=2C OK-=
Jefferson=2C OK-Johnston=2C OK-Kay=2C OK-Kingfisher=2C OK-Kiowa=2C OK-Latim=
er=2C OK-Le Flore=2C OK-Lincoln=2C OK-Logan=2C OK-Love=2C OK-Major=2C OK-Ma=
rshall=2C OK-Mayes=2C OK-McClain=2C OK-McCurtain=2C OK-McIntosh=2C OK-Murra=
y=2C OK-Muskogee=2C OK-Noble=2C OK-Nowata=2C OK-Okfuskee=2C OK-Oklahoma=2C =
OK-Okmulgee=2C OK-Osage=2C OK-Ottawa=2C OK-Pawnee=2C OK-Payne=2C OK-Pittsbu=
rg=2C OK-Pontotoc=2C OK-Pottawatomie=2C OK-Pushmataha=2C OK-Roger Mills=2C =
OK-Rogers=2C OK-Seminole=2C OK-Sequoyah=2C OK-Stephens=2C OK-Texas=2C OK-Ti=
llman=2C OK-Tulsa=2C OK-Wagoner=2C OK-Washington=2C OK-Washita=2C OK-Woods=
=2C OK-Woodward=2C OK
"=3B
$state_colors=3D "#FFFFCC-#FFFFCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#=
FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCC CC-#FFCCCC-#FFC=
CCC-#FFCCCC-#FFCCCC-#FFCCCC-#FF9999-#FF9999-#FF9999-#FF9999- #FF9999-#FF9999=
-#FF9999-#FF9999-#FF9999-#FF9999-#FF9999-#FF9999-#FF9999-#FF 9999-#FF9999-#F=
F9999-#FF9999-#FF9999-#FF9999-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCF F-#0DCCFF-#0DCC=
FF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-# 0DCCFF-#0DCCFF-=
#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DC CFF-#0DCCFF-#0D=
CCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF -#0DCCFF-#0DCCF=
F-#0DCCFF-#0DCCFF-#0DCCFF-#0DCCFF"=3B
$change=3D "207-158-189-220-134-74.9-174-75.1-38-125-173-215-390-39-141 -92.=
1-121-175-80.1-95.4-191-124-169-101-77-52-117-155-188-176-16 9-114-158-122-1=
41-107-43-122-181-223-53.7-41.5-131-112-144-147-48-249-141-1 01-155-81.4-158=
-92.3-16.3-105-153-186-108-69.2-146-103-53.4-225-140-136-80. 4-179-93.3-277-=
136-110-136-143-103-183-141";;

$from =3D explode("-"=2C $from)=3B
$state_colors=3D explode("-"=2C $state_colors)=3B
$change =3D explode("-"=2C$change)=3B

$new_array =3D array_combine($from=2C$change)=3B
asort($new_array)=3B

foreach ($new_array as $key =3D> $value) echo $key . " is " . $value . " mi=
les away
"=3B //this does sort numerically.=20

The question you asked me earlier in the email=2C location2 is supposed to =
be one of the elements in the $from array=2C which is why I thought I could=
just do a=20

$key=3D array_keys($new_array=2C$location2)=3B //Find out the position of=
the index in the array =20

and find its index. In my case now=2C could you please give me some tips on=
how I could find the "index" of the $new_array array?=20

Thanks.=20
=20
Alice
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up now.=
=20
____________________________________________________________ _____
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/=

--_63e038d0-1634-4a4e-a728-3267609d69fe_--

Re: Array Search Not Working?

am 10.03.2010 18:08:34 von Shawn McKenzie

Alice Wei wrote:
> From: ajwei@alumni.iu.edu
> To: nospam@mckenzies.net
> CC: php-general@lists.php.net
> Subject: RE: Array Search Not Working?
> Date: Wed, 10 Mar 2010 11:21:26 -0500

I'm still a little foggy on what you're doing, but doing, but does this
help?

$from = explode("-", $from);
$state_colors = explode("-", $state_colors);
$change = explode("-", $change);

$old = array_combine($from, $state_colors);
$new = array_combine($from, $change);

//show all values
foreach($old as $key => $val) {
echo "{$key} old={$old[$key]} new={$new[$key]}
\n";
}

//lookup a particular value
$test = "Muskogee, OK";
echo "TEST={$test} old={$old[$test]} new={$new[$test]}
\n";

/*
I'm proud to be an Okie from Muskogee,
A place where even squares can have a ball
We still wave Old Glory down at the courthouse,
And white lightnin's still the biggest thrill of all
*/

--
Thanks!
-Shawn
http://www.spidean.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Array Search Not Working?

am 10.03.2010 18:21:57 von Alice Wei

--_8c6e520d-6050-4b22-9fdc-b2cd9365c270_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable


>=20
> I'm still a little foggy on what you're doing=2C but doing=2C but does th=
is
> help?
>=20
> $from =3D explode("-"=2C $from)=3B
> $state_colors =3D explode("-"=2C $state_colors)=3B
> $change =3D explode("-"=2C $change)=3B
>=20
> $old =3D array_combine($from=2C $state_colors)=3B
> $new =3D array_combine($from=2C $change)=3B
>=20
> //show all values
> foreach($old as $key =3D> $val) {
> echo "{$key} old=3D{$old[$key]} new=3D{$new[$key]}
\n"=3B
> }
>=20
> //lookup a particular value
> $test =3D "Muskogee=2C OK"=3B
> echo "TEST=3D{$test} old=3D{$old[$test]} new=3D{$new[$test]}
\n"=
=3B
>=20

Well=2C here is the weird part. put up the last 3 lines of your code here i=
nto mine=2C and here is the output:TEST=3DMuskogee=2C OK old=3D new=
I am starting to wonder if there are other things hidden inside the "values=
" that seems like that the values of the new array (the state and counties =
part) are the same as the original when I tried to do the comparison. This =
is what I mean by the fact that my array_search does not work=2C and all I =
am trying to do is to find the index=2C so I can do stateColors[$index] lat=
er on and color my map.=20

Have I done something wrong here that causes the code you provided not to s=
pit out anything here? This is what I have:

$from =3D explode("-"=2C $from)=3B
$state_colors=3D explode("-"=2C $state_colors)=3B
$change =3D explode("-"=2C$change)=3B

$new_array =3D array_combine($from=2C$change)=3B
asort($new_array)=3B

foreach ($new_array as $key =3D> $value) echo $key . " is " . $value . " mi=
les away
"=3B

Thanks.=20

Alice
=20
____________________________________________________________ _____
Hotmail: Trusted email with Microsoft=92s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/201469226/direct/01/=

--_8c6e520d-6050-4b22-9fdc-b2cd9365c270_--

Re: Array Search Not Working?

am 11.03.2010 06:49:25 von Clancy

On Wed, 10 Mar 2010 09:52:30 -0500, ajwei@alumni.iu.edu (Alice Wei) wrote:

>
>Hi,
>
> I have two arrays here that I have combined into a new array, as shown here:
>
>$from = explode("-", $from);
>$change = explode("-",$change);
>$new_array = array_combine($from,$change);
>
>I then tried reading it from a file and do string matches, trying to find out the "key" using the array_search of the individual array elements. I seem to have no such luck, even when I copied one of the elements after I do a print_r($new_array);
>
>Here is the code,
>
>foreach ($lines2 as $line_num => $line2) {
>$style_line_num = $line_num+3;
>
> if(preg_match("/^style/",$line2)) {
>
> if(preg_match("/inkscape:label/",$lines2[$style_line_num])) {
> $location = explode("=",$lines2[$style_line_num]);
> $location2 = substr($patient_location[1],1,-6);
>
> if(in_array($location2, $from)) {
> $key= array_search($location2,$new_array); //Find out the position of the index in the array
> echo "Key " . $key . "
"; //This only gives me a blank space after the word Key
>
> }
>
> } //end preg_match inkscape
> } //If preg_match style
>
>I looked at the example from http://php.net/manual/en/function.array-search.php, and looks like what I am trying to do here is possible, and yet, why am I not getting a proper key return?
>
>Thanks for your help.
>
>Alice

I have a very handy utility for problems like this:

// Expand string array, & list all terms
function larec($array, $name) // List array recursive
{
if (is_array($array))
{
$j = count ($array);
$temp = array_keys($array);
$i = 0; while ($i < $j)
{
if(isset($array[$temp[$i]]))
{
$new_line = $name."['".$temp[$i]."']";
larec ($array[$temp[$i]], $new_line);
}
$i++;
}
}
else
{
echo '

'.$name.' = '.$array.'

';
}
}

If you have some array $foo then larec($foo,'Foo'); will list all the elements of $foo
recursively, without any obvious limits. This makes it very easy to see what you have
actually got, as opposed to what you thought you would get. The following is an abridged
example of the result of listing an array $wkg_sys of mine, using:

larec ($wkg_sys,'Sys');

Sys['class'] = W

Sys['style']['0']['wkg_style'] = basic_tab
Sys['style']['0']['pad'] =
Sys['style']['0']['stripe'] = 0
Sys['style']['1']['wkg_style'] = nrml_style
Sys['style']['1']['pad'] = 1
Sys['style']['1']['stripe'] = 0

Sys['valid'] = 1
Sys['entries'] = 15
Sys['f_title'] = Developmental Web Page
Sys['version'] = IF1.4
Sys['ident'] = 0800
Sys['directory_id'] = 0000
Sys['index'] = 2
Sys['date'] = CCY2N

Clancy

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php