[PHP] RE: Possible bug? (was Re: [PHP] Arrays: Please help before I go insane?)

2002-06-06 Thread Scott Hurring

When i run your code, the result is 100% correct, even
though you're outputting the wrong text label to go along
with the value 
you say "branch[one][two]" = $branch[one]
and since $branch[one] *IS* an Array, the output is correct
(even though "branch[one][two]" is NOT an Array --
very very important difference)

Here's my output of the code below:

SET == SET
Passing to getParentNodes:
currentBranch[one][two] = Array




---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 4:43 PM
> To: Scott Hurring; Php-General (E-mail)
> Subject: Possible bug? (was Re: [PHP] Arrays: Please help before I go
> insane?)
> 
> 
> > In that case, split it up into two-steps, to only init the
> > array if you need to i'm not really sure how the rest of
> > your code is -- you could probably do this a nicer way,
> > but this will work:
> > if (!is_array($ary["this"]))
> > $ary["this"] = array();
> > $ary["this"]["that"] = 1;
> 
> This is all well and good.  But I'm already doing that last 
> one and it's 
> that last that is getting messed up.
> 
> Again, if you look at the page I gave the link for, you'll 
> see where it 
> says:
> 
> currentBranch[other][joe] = Array
> 
> (all good) but the next line it says:
> 
> Passing to getParentNodes: currentBranch[joe][monster] = SET
> 
> which it shouldn't.  Where it says "SET" it should say "Array".  This
> is what my code is doing:
> 
> --
> 
> $currentBranch["$nodeName"]["{$nodeInfo[parent]}"] = "SET";
> 
> echo "Passing to getParentNodes: 
> currentBranch[$nodeName][{$nodeInfo[parent]}] = " . 
> $currentBranch["$nodeName"] . "\n";
> 
> --
> 
> $nodeInfo[parent] is a valid value.  So $currentBranch["$nodeName"]
> should be an array after that.  However, by some miracle (or bug in 
> PHP), instead of printing out "Array", it's print out "SET".  
> And I have
> no idea why it's doing that in my code.  The above works fine 
> by itself,
> however in my function it doesn't *even though they are doing the same
> things with no other code between*.
> 
> Chris
> 
> 

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




[PHP] Possible bug? (was Re: [PHP] Arrays: Please help before I go insane?)

2002-06-06 Thread Chris Boget

> In that case, split it up into two-steps, to only init the
> array if you need to i'm not really sure how the rest of
> your code is -- you could probably do this a nicer way,
> but this will work:
> if (!is_array($ary["this"]))
> $ary["this"] = array();
> $ary["this"]["that"] = 1;

This is all well and good.  But I'm already doing that last one and it's 
that last that is getting messed up.

Again, if you look at the page I gave the link for, you'll see where it 
says:

currentBranch[other][joe] = Array

(all good) but the next line it says:

Passing to getParentNodes: currentBranch[joe][monster] = SET

which it shouldn't.  Where it says "SET" it should say "Array".  This
is what my code is doing:

--

$currentBranch["$nodeName"]["{$nodeInfo[parent]}"] = "SET";

echo "Passing to getParentNodes: 
currentBranch[$nodeName][{$nodeInfo[parent]}] = " . 
$currentBranch["$nodeName"] . "\n";

--

$nodeInfo[parent] is a valid value.  So $currentBranch["$nodeName"]
should be an array after that.  However, by some miracle (or bug in 
PHP), instead of printing out "Array", it's print out "SET".  And I have
no idea why it's doing that in my code.  The above works fine by itself,
however in my function it doesn't *even though they are doing the same
things with no other code between*.

Chris



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




RE: [PHP] Arrays: Please help before I go insane?

2002-06-06 Thread Scott Hurring

In that case, split it up into two-steps, to only init the
array if you need to i'm not really sure how the rest of
your code is -- you could probably do this a nicer way,
but this will work:

if (!is_array($ary["this"]))
$ary["this"] = array();

$ary["this"]["that"] = 1;

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 3:43 PM
> To: Scott Hurring
> Cc: PHP General
> Subject: Re: [PHP] Arrays: Please help before I go insane?
> 
> 
> > Try:  $ary["this"] = array("that" => 1);
> 
> That works great until "this" has 2 children.  The second child 
> overwrites the first. :(
> 
> Chris
> 
> 

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




Re: [PHP] Arrays: Please help before I go insane?

2002-06-06 Thread Chris Boget

> Try:  $ary["this"] = array("that" => 1);

That works great until "this" has 2 children.  The second child 
overwrites the first. :(

Chris



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




RE: [PHP] Arrays: Please help before I go insane?

2002-06-06 Thread Scott Hurring

Try:  $ary["this"] = array("that" => 1);



---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 1:48 PM
> To: PHP General
> Subject: Re: [PHP] Arrays: Please help before I go insane?
> 
> 
> > Now, what I'm trying to do is build a tree based on the 
> data in the DB.  
> > It's working relatively ok if I uncomment the code that is 
> on line 48 and 
> > comment out line 49.  However, what I really want to do is 
> build a fully 
> > associative array doing this and now** an array that has 
> string keys but 
> > then, those arrays having numeric keys (copy and run this code 
> > un/commenting the lines above and you'll see what I mean).
> 
> ** should be "not"
> 
> To elaborate, what I'm trying to do is build an array that 
> looks like this:
> 
> $array["this"]["that"] = "whatever";
> $array["this"]["other"] = "whatever";
> 
> and not one that looks like this:
> 
> $array["this"][0] = "that";
> $array["this"][1] = "other";
> 
> because I just want to be able to get the keys and not have to worry
> about when I should be using the value of the key or the value of the
> array element.
> 
> Again, the problem that I'm having (as demonstrated by the code) is
> that when I'm trying to set it up so that it's like the first 
> example above,
> 
> $array["this"]
> 
> isn't always evaluating as an array, though it always should.
> 
> Chris
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




Re: [PHP] Arrays: Please help before I go insane?

2002-06-06 Thread Chris Boget

> Now, what I'm trying to do is build a tree based on the data in the DB.  
> It's working relatively ok if I uncomment the code that is on line 48 and 
> comment out line 49.  However, what I really want to do is build a fully 
> associative array doing this and now** an array that has string keys but 
> then, those arrays having numeric keys (copy and run this code 
> un/commenting the lines above and you'll see what I mean).

** should be "not"

To elaborate, what I'm trying to do is build an array that looks like this:

$array["this"]["that"] = "whatever";
$array["this"]["other"] = "whatever";

and not one that looks like this:

$array["this"][0] = "that";
$array["this"][1] = "other";

because I just want to be able to get the keys and not have to worry
about when I should be using the value of the key or the value of the
array element.

Again, the problem that I'm having (as demonstrated by the code) is
that when I'm trying to set it up so that it's like the first example above,

$array["this"]

isn't always evaluating as an array, though it always should.

Chris





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