Re: [PHP] array question

2010-12-20 Thread Ravi Gehlot
Jim Lucas has it. You can use the preg_match function to find it. I would
use regexp for that reason. regexp is good for making sure things are typed
the way they need to (mostly used for).

Ravi.


On Sat, Dec 18, 2010 at 5:17 PM, Jim Lucas  wrote:

> On 12/17/2010 12:52 PM, Sorin Buturugeanu wrote:
>
>> Hello all!
>>
>> I have a question regarding arrays and the way I can use a value.
>>
>> Let's say I have this string:
>>
>> $s = 'banana,apple,mellon,grape,nut,orange'
>>
>> I want to explode it, and get the third value. For this I would normally
>> do:
>>
>> $a = explode(',', $s);
>> echo $s[2];
>>
>> That's all fine, but is there a way to get the value directly, without
>> having to write another line in my script. I mean something like this:
>>
>> echo explode(',', $s)[2];
>>
>> or
>>
>> echo {explode(',', $s)}[2];
>>
>> I couldn't find out this answer anywhere, that's why I posted here.
>>
>> Cheers and thanks!
>>
>>
> Sure it CAN be done.  Nobody laugh too loud here... But...
>
> 
> $s = 'banana,apple,mellon,grape,nut,orange';
> echo preg_replace('/([^,]+,){3}([^,]+).*/', '$2', $s);
>
> ?>
> Outputs: grape
>
> The {3} part is equivalent to the array position.  Change that number, and
> you change which word will get displayed.
>
> Jim Lucas
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] array question

2010-12-18 Thread Jim Lucas

On 12/17/2010 12:52 PM, Sorin Buturugeanu wrote:

Hello all!

I have a question regarding arrays and the way I can use a value.

Let's say I have this string:

$s = 'banana,apple,mellon,grape,nut,orange'

I want to explode it, and get the third value. For this I would normally do:

$a = explode(',', $s);
echo $s[2];

That's all fine, but is there a way to get the value directly, without
having to write another line in my script. I mean something like this:

echo explode(',', $s)[2];

or

echo {explode(',', $s)}[2];

I couldn't find out this answer anywhere, that's why I posted here.

Cheers and thanks!



Sure it CAN be done.  Nobody laugh too loud here... But...


Outputs: grape

The {3} part is equivalent to the array position.  Change that number, 
and you change which word will get displayed.


Jim Lucas

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



Re: [PHP] array question

2010-12-17 Thread Sorin Buturugeanu
Tanks for all of your responses!

I guess a function is the way to go. I just have to see if the situation
comes up enough times to justify the function approach.

@Dan: I really enjoyed your disclaimer :D


--
Sorin Buturugeanu
www.soin.ro

blog:
Despre Launch48 si ce poti face in 2 zile 



On 17 December 2010 23:48, Daniel Brown  wrote:

> On Fri, Dec 17, 2010 at 15:52, Sorin Buturugeanu  wrote:
> > Hello all!
> >
> > I have a question regarding arrays and the way I can use a value.
> >
> > Let's say I have this string:
> >
> > $s = 'banana,apple,mellon,grape,nut,orange'
> >
> > I want to explode it, and get the third value. For this I would normally
> do:
> >
> > $a = explode(',', $s);
> > echo $s[2];
> >
> > That's all fine, but is there a way to get the value directly, without
> > having to write another line in my script. I mean something like this:
> >
> > echo explode(',', $s)[2];
> >
> > or
> >
> > echo {explode(',', $s)}[2];
> >
> > I couldn't find out this answer anywhere, that's why I posted here.
>
> Unfortunately, no --- at least, not yet.  Chaining discussions
> come up now and again, so it's quite possible that future versions of
> PHP will have something similar.  That said, for now you could do
> something like this:
>
>  /**
>  * mixed return_item( string $car, mixed $pos )
>  *  - $str The original string
>  *  - $charThe delimiting character(s) by which to explode
>  *  - $pos The position to return
>  *  - $shift   Whether or not we should see 1 as the first array position
>  */
> function return_item($str,$char,$pos=null,$shift=false) {
>
>// Make sure $char exists in $str, return false if not.
>if (!strpos($str,$char)) return false;
>
>// Split $char by $str into the array $arr
>$arr = explode($char,$str);
>
>// If $pos undefined or null, return the whole array
>if (is_null($pos)) return $arr;
>
>// If $pos is an array, return the requested positions
>if (isset($pos) && is_array($pos) && !empty($pos)) {
>
>// Instantiate a second array container for return
>$ret = array();
>
>// Iterate
>foreach ($pos as $i) {
>
>// This is just in case it was given screwy or a number as
> a non-integer
>if (!is_int($i) && is_numeric($i)) $i = (int)round($i);
>
>// Make sure $i is now an integer and that position exists
>if (!is_int($i) || !isset($arr[$i]) || empty($arr[$i]))
> continue;
>
>// If all seems okay, append this to $ret
>$ret[] = $arr[$i];
>}
>
>// Return the array
>return $ret;
>}
>
>/**
>  * If $pos is a number (integer or round()'able number),
>  * we'll go ahead and make sure the position is there.
>  * If so, we'll return it.
>  */
>if (is_int($pos) || is_numeric($pos)) {
>
>// This is just in case it was given screwy or as a non-integer
>if (!is_int($pos)) $pos = (int)round($pos);
>
>// If we want to start the array count at 1, do that now
>if (isset($shift) && ($shift === true || $shift === 1)) {
>
>//  but only if the number isn't zero
>if ($pos !== 0) --$pos;
>
>}
>
>// Return the single position if it exists
>if (isset($arr[$pos]) && !empty($arr[$pos])) return $arr[$pos];
>}
>
>/**
> * If we've failed every case, something is either
> * wrong or we supplied bad data.  Return false.
> * Either way, feel free to add some trigger_error()
> * stuff here if you want to have the function hold
> * your hand.
> */
>return false;
> }
>
>
>
> /**
>  * Some simple examples
>  */
>
> $foo =
> 'apple,banana,carrot,orange,carrot,lettuce,tomato,beer,carrot,idiot';
>
> return_item($foo,',',7); // Returns 'beer'
> return_item($foo,'carrot',0); // Returns 'apple,banana,'
> return_item($foo,','); // Returns all items in an array
> return_item($foo,',',array(0,'2',6.6)); // Returns array: apple,carrot,beer
> return_item($foo,',',1,true); // Returns 'apple'
> ?>
>
>
>Of course, as with almost all code I submit here, it's typed
> directly into this window and is untested, so you use it at your own
> risk, your mileage may vary, see a doctor if you have an erection
> lasting more than four hours, et cetera.
>
>Happy Friday, all.
>
> --
> 
> Network Infrastructure Manager
> Documentation, Webmaster Teams
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] array question

2010-12-17 Thread Daniel Brown
On Fri, Dec 17, 2010 at 15:52, Sorin Buturugeanu  wrote:
> Hello all!
>
> I have a question regarding arrays and the way I can use a value.
>
> Let's say I have this string:
>
> $s = 'banana,apple,mellon,grape,nut,orange'
>
> I want to explode it, and get the third value. For this I would normally do:
>
> $a = explode(',', $s);
> echo $s[2];
>
> That's all fine, but is there a way to get the value directly, without
> having to write another line in my script. I mean something like this:
>
> echo explode(',', $s)[2];
>
> or
>
> echo {explode(',', $s)}[2];
>
> I couldn't find out this answer anywhere, that's why I posted here.

Unfortunately, no --- at least, not yet.  Chaining discussions
come up now and again, so it's quite possible that future versions of
PHP will have something similar.  That said, for now you could do
something like this:




Of course, as with almost all code I submit here, it's typed
directly into this window and is untested, so you use it at your own
risk, your mileage may vary, see a doctor if you have an erection
lasting more than four hours, et cetera.

Happy Friday, all.

-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



RE: [PHP] array question

2010-12-17 Thread Jay Blanchard
[snip]
I have a question regarding arrays and the way I can use a value.

Let's say I have this string:

$s = 'banana,apple,mellon,grape,nut,orange'

I want to explode it, and get the third value. For this I would normally
do:

$a = explode(',', $s);
echo $s[2];

That's all fine, but is there a way to get the value directly, without
having to write another line in my script. I mean something like this:

echo explode(',', $s)[2];

or

echo {explode(',', $s)}[2];

I couldn't find out this answer anywhere, that's why I posted here.
[/snip]

Because the array is not formed until after the explode you cannot do it
with one command, but you could place 2 commands on one line :)

$a = explode(',', $s); echo $a[2];

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



Re: [PHP] Array question

2010-09-26 Thread tedd

At 3:31 PM -0500 9/25/10, MikeB wrote:

-snip-

My question, in the loop, why does tha author use:

$results[] = mysql_fetch_array($result);

instead of (as I would expect):

$results[$j] = mysql_fetch_array($result);?

What PHP magic is at work here?


Mike:

That's just a shorthand way to populate an array in PHP.

One of the reasons for this feature is that somewhere in your code 
you may not know what the next index should be. So, if you use --


$results[] = $next_item;

-- then the $next_item will be "automagically" added to the next 
available index in the array. So you may be right in calling it "PHP 
magic" because I have not seen this in other languages.


Understand?

Cheers,

tedd
--
---
http://sperling.com/

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



Re: [PHP] Array question

2010-09-26 Thread a...@ashleysheridan.co.uk
I'd also like to add to that:

$array = array();
$array[] = 'text';
$array[2] = 123;
$array[] = 'hello';

Would output:

$array(
0 => 'text',
2 => 123,
3 => 'hello',
);

Note the missing index 1, as php makes a numerical index that is one greater 
than the highest already in use. As the index 2 was explicitly created, php 
made the next one at 3.

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "chris h" 
Date: Sat, Sep 25, 2010 22:05
Subject: [PHP] Array question
To: "MikeB" 
Cc: 


Mike,

$results[] will automatically push a value unto the end of an array.

So doing this...
--
$magic = array();
$magic[] = 'a';
$magic[] = 'b';
$magic[] = 'c';
-

is exactly this same as doing this...
--
$normal = array();
$normal[0] = 'a';
$normal[1] = 'b';
$normal[2] = 'c';
-

And yes, in your example "$results[]" would be equivalent to "$results[$j]"


For more reference:
http://www.php.net/manual/en/language.types.array.php


Chris H.


On Sat, Sep 25, 2010 at 4:31 PM, MikeB  wrote:

> I have the following code:
>
> $query = "SELECT * FROM classics";
> $result = mysql_query($query);
>
> if (!$result) die ("Database access failed: " . mysql_error());
> $rows = mysql_num_rows($result);
>
> for ($j = 0 ; $j < $rows ; ++$j)
> {
>$results[] = mysql_fetch_array($result);
> }
>
> mysql_close($db_server);
>
> My question, in the loop, why does tha author use:
>
> $results[] = mysql_fetch_array($result);
>
> instead of (as I would expect):
>
> $results[$j] = mysql_fetch_array($result);?
>
> What PHP magic is at work here?
>
> Thanks.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Array question

2010-09-25 Thread chris h
Mike,

$results[] will automatically push a value unto the end of an array.

So doing this...
--
$magic = array();
$magic[] = 'a';
$magic[] = 'b';
$magic[] = 'c';
-

is exactly this same as doing this...
--
$normal = array();
$normal[0] = 'a';
$normal[1] = 'b';
$normal[2] = 'c';
-

And yes, in your example "$results[]" would be equivalent to "$results[$j]"


For more reference:
http://www.php.net/manual/en/language.types.array.php


Chris H.


On Sat, Sep 25, 2010 at 4:31 PM, MikeB  wrote:

> I have the following code:
>
> $query = "SELECT * FROM classics";
> $result = mysql_query($query);
>
> if (!$result) die ("Database access failed: " . mysql_error());
> $rows = mysql_num_rows($result);
>
> for ($j = 0 ; $j < $rows ; ++$j)
> {
>$results[] = mysql_fetch_array($result);
> }
>
> mysql_close($db_server);
>
> My question, in the loop, why does tha author use:
>
> $results[] = mysql_fetch_array($result);
>
> instead of (as I would expect):
>
> $results[$j] = mysql_fetch_array($result);?
>
> What PHP magic is at work here?
>
> Thanks.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Array Question

2007-07-17 Thread kvigor
Thanks for all the input.  You've all been pretty informative.  Sorry of 
delayed response to help but was busy.  You all are appreciated.


"Stut" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Richard Lynch wrote:
>> On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote:
 But I'd have to say that the intent is not all that clear, really,
 and
 I'd be leery of this feature, personally.
>>> I wouldn't be leery at all. It's been around for a very long time and
>>> it's documented:
>>>
>>>
>>> http://www.php.net/manual/en/language.types.array.php#language.types.array.casting
>>
>> As soon as I hit send I knew that would be mis-interpreted...
>>
>> Leery is the wrong word.
>>
>> Sorry.
>>
>> It just seems a bit to clever to me...
>>
>> I suspect I'd skim this code a hundred times and not realize what it
>> was doing.
>>
>> But maybe that's just me. :-)
>
> I would have to agree. I'm a big fan of self-documenting code, and this 
> one requires a little bit more knowledge of the intricacies of PHP than I 
> would expect from your 'average' developer.
>
> If performance is going to be an issue (and in terms of cycles I can't see 
> this saving much), buy faster/more hardware - it's far cheaper than 
> developer time!!
>
> -Stut
>
> -- 
> http://stut.net/ 

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



Re: [PHP] Array Question

2007-07-14 Thread Robert Cummings
On Sat, 2007-07-14 at 00:55 -0500, Richard Lynch wrote:
> On Fri, July 13, 2007 2:15 am, Richard Lynch wrote:
> > On Thu, July 12, 2007 8:29 am, Robert Cummings wrote:
> >> Hmmm, I thought using an explicit cast was very self explanatory --
> >> especially when the name of the cast is "array". Maybe I'm alone in
> >> that
> >> thought. I mean if you convert a scalar to an array what do you
> >> expect
> >> to get? An array with the scalar. *shrug* I can't see how it would
> >> be
> >> anything else.
> >
> > $foo = (array) 'foo';
> > var_dump($foo);
> >
> > A couple perfectly reasonable (though wrong) outputs:
> >
> > #1
> > array (3){
> >   0 => 'f',
> >   1 => 'o',
> >   2 => 'o'
> > );
> >
> > And, actually, PHP having been derived (partially) from C, one could
> > almost argue this is the EXPECTED output. :-)
> 
> In retrospect, given that $foo[1] is 'o' and that you can treat $foo
> JUST like an array of characters, the EXPECTED output from a C->PHP
> perspective might be:
> 
> string (3) 'foo'
> 
> It already *IS* an array, to a large extent.
> 
> :-)

When in Rome do as the Romans. PHP has a very distinct definition for an
array and for a string. If you think you're using C then maybe you
should go read the documentation. Assumptions based on previous
experience only go as far as they are right. Since you explicitly cast
to an array and not to a string, it can only be expected that you have
an array -- or an exception as you previously offered. But we know you
get an array because it's documented.

:)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-13 Thread Richard Lynch
On Fri, July 13, 2007 2:15 am, Richard Lynch wrote:
> On Thu, July 12, 2007 8:29 am, Robert Cummings wrote:
>> Hmmm, I thought using an explicit cast was very self explanatory --
>> especially when the name of the cast is "array". Maybe I'm alone in
>> that
>> thought. I mean if you convert a scalar to an array what do you
>> expect
>> to get? An array with the scalar. *shrug* I can't see how it would
>> be
>> anything else.
>
> $foo = (array) 'foo';
> var_dump($foo);
>
> A couple perfectly reasonable (though wrong) outputs:
>
> #1
> array (3){
>   0 => 'f',
>   1 => 'o',
>   2 => 'o'
> );
>
> And, actually, PHP having been derived (partially) from C, one could
> almost argue this is the EXPECTED output. :-)

In retrospect, given that $foo[1] is 'o' and that you can treat $foo
JUST like an array of characters, the EXPECTED output from a C->PHP
perspective might be:

string (3) 'foo'

It already *IS* an array, to a large extent.

:-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Array Question

2007-07-13 Thread Robert Cummings
On Fri, 2007-07-13 at 02:15 -0500, Richard Lynch wrote:
> On Thu, July 12, 2007 8:29 am, Robert Cummings wrote:
> > Hmmm, I thought using an explicit cast was very self explanatory --
> > especially when the name of the cast is "array". Maybe I'm alone in
> > that
> > thought. I mean if you convert a scalar to an array what do you expect
> > to get? An array with the scalar. *shrug* I can't see how it would be
> > anything else.
> 
> $foo = (array) 'foo';
> var_dump($foo);
> 
> A couple perfectly reasonable (though wrong) outputs:
> 
> #1
> array (3){
>   0 => 'f',
>   1 => 'o',
>   2 => 'o'
> );
> 
> And, actually, PHP having been derived (partially) from C, one could
> almost argue this is the EXPECTED output. :-)
> 
> 
> #2
> array (1) {
>   'foo' => 'foo'
> }
> 
> Which might work just fine for whatever the original code was doing,
> but isn't quite the same as what happens...
> 
> #3
> array (1) {
>   'foo' => TRUE
> }
> 
> Bit of a stretch, I suppose...
> 
> #4
> ERROR: Invalid typecast of String to Array.
> 
> Not very PHP, I suppose, but there it is...

Waves hands wildly and dismissively in the air. *pshaw*

:)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-13 Thread Richard Lynch
On Thu, July 12, 2007 8:29 am, Robert Cummings wrote:
> Hmmm, I thought using an explicit cast was very self explanatory --
> especially when the name of the cast is "array". Maybe I'm alone in
> that
> thought. I mean if you convert a scalar to an array what do you expect
> to get? An array with the scalar. *shrug* I can't see how it would be
> anything else.

$foo = (array) 'foo';
var_dump($foo);

A couple perfectly reasonable (though wrong) outputs:

#1
array (3){
  0 => 'f',
  1 => 'o',
  2 => 'o'
);

And, actually, PHP having been derived (partially) from C, one could
almost argue this is the EXPECTED output. :-)


#2
array (1) {
  'foo' => 'foo'
}

Which might work just fine for whatever the original code was doing,
but isn't quite the same as what happens...

#3
array (1) {
  'foo' => TRUE
}

Bit of a stretch, I suppose...

#4
ERROR: Invalid typecast of String to Array.

Not very PHP, I suppose, but there it is...



-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Array Question

2007-07-12 Thread Robert Cummings
On Thu, 2007-07-12 at 09:58 +0100, Stut wrote:
> Richard Lynch wrote:
> > On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote:
> >>> But I'd have to say that the intent is not all that clear, really,
> >>> and
> >>> I'd be leery of this feature, personally.
> >> I wouldn't be leery at all. It's been around for a very long time and
> >> it's documented:
> >>
> >>
> >> http://www.php.net/manual/en/language.types.array.php#language.types.array.casting
> > 
> > As soon as I hit send I knew that would be mis-interpreted...
> > 
> > Leery is the wrong word.
> > 
> > Sorry.
> > 
> > It just seems a bit to clever to me...
> > 
> > I suspect I'd skim this code a hundred times and not realize what it
> > was doing.
> > 
> > But maybe that's just me. :-)
> 
> I would have to agree. I'm a big fan of self-documenting code, and this 
> one requires a little bit more knowledge of the intricacies of PHP than 
> I would expect from your 'average' developer.

Hmmm, I thought using an explicit cast was very self explanatory --
especially when the name of the cast is "array". Maybe I'm alone in that
thought. I mean if you convert a scalar to an array what do you expect
to get? An array with the scalar. *shrug* I can't see how it would be
anything else.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-12 Thread Stut

Richard Lynch wrote:

On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote:

But I'd have to say that the intent is not all that clear, really,
and
I'd be leery of this feature, personally.

I wouldn't be leery at all. It's been around for a very long time and
it's documented:


http://www.php.net/manual/en/language.types.array.php#language.types.array.casting


As soon as I hit send I knew that would be mis-interpreted...

Leery is the wrong word.

Sorry.

It just seems a bit to clever to me...

I suspect I'd skim this code a hundred times and not realize what it
was doing.

But maybe that's just me. :-)


I would have to agree. I'm a big fan of self-documenting code, and this 
one requires a little bit more knowledge of the intricacies of PHP than 
I would expect from your 'average' developer.


If performance is going to be an issue (and in terms of cycles I can't 
see this saving much), buy faster/more hardware - it's far cheaper than 
developer time!!


-Stut

--
http://stut.net/

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



Re: [PHP] Array Question

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 16:40 -0500, Richard Lynch wrote:
> On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote:
> >> But I'd have to say that the intent is not all that clear, really,
> >> and
> >> I'd be leery of this feature, personally.
> >
> > I wouldn't be leery at all. It's been around for a very long time and
> > it's documented:
> >
> >
> > http://www.php.net/manual/en/language.types.array.php#language.types.array.casting
> 
> As soon as I hit send I knew that would be mis-interpreted...

Glad I didn't disappoint :)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-11 Thread Richard Lynch
On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote:
>> But I'd have to say that the intent is not all that clear, really,
>> and
>> I'd be leery of this feature, personally.
>
> I wouldn't be leery at all. It's been around for a very long time and
> it's documented:
>
>
> http://www.php.net/manual/en/language.types.array.php#language.types.array.casting

As soon as I hit send I knew that would be mis-interpreted...

Leery is the wrong word.

Sorry.

It just seems a bit to clever to me...

I suspect I'd skim this code a hundred times and not realize what it
was doing.

But maybe that's just me. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Array Question

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 16:11 -0500, Richard Lynch wrote:
> On Wed, July 11, 2007 9:52 am, Stut wrote:
> >> $needle = (array)$needle;
> >>
> >> Conversion to array creates an array with one element... the value
> >> converted.
> >
> > Without raising a notice?
> 
> Sure looks like it:
> php -d error_reporting=2047 -r '$foo = (array) "foo"; var_dump($foo);'
> array(1) {
>   [0]=>
>   string(3) "foo"
> }
> 
> But I'd have to say that the intent is not all that clear, really, and
> I'd be leery of this feature, personally.

I wouldn't be leery at all. It's been around for a very long time and
it's documented:


http://www.php.net/manual/en/language.types.array.php#language.types.array.casting

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-11 Thread Richard Lynch
On Wed, July 11, 2007 9:52 am, Stut wrote:
>> $needle = (array)$needle;
>>
>> Conversion to array creates an array with one element... the value
>> converted.
>
> Without raising a notice?

Sure looks like it:
php -d error_reporting=2047 -r '$foo = (array) "foo"; var_dump($foo);'
array(1) {
  [0]=>
  string(3) "foo"
}

But I'd have to say that the intent is not all that clear, really, and
I'd be leery of this feature, personally.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Array Question

2007-07-11 Thread Robin Vickery

On 11/07/07, Robert Cummings <[EMAIL PROTECTED]> wrote:

On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote:
> On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:
> > Is there a php function similar to in_array that can detect if a "partial
> > value" is in an array value or not:
> >
> > e.g.
> >
> > $var1 = " big horse";$var2 = " small yellow";$var3 = " red hydrant";
> >
> > $theArray = array(big blue horse, small yellow bird, giant red hydrant);
> >
> > Is there a way to find out if $var1 in $theArray or $var2 etc.?
>
> There's not a built in function, but it's not hard to write one:
>
> function partial_in_array($needle, $haystack) {
>   if (!is_array($needle)) { $needle = array($needle); }

You can reduce the above statement to the following:

$needle = (array)$needle;

Conversion to array creates an array with one element... the value
converted.


Fair enough. I very rarely type cast in PHP, so it never occurred to
me to try that.

-robin

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



Re: [PHP] Array Question

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 16:07 +0100, Stut wrote:
> Robert Cummings wrote:
> > On Wed, 2007-07-11 at 15:52 +0100, Stut wrote:
> >> Robert Cummings wrote:
> >>> On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote:
>  On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:
> > Is there a php function similar to in_array that can detect if a 
> > "partial
> > value" is in an array value or not:
> >
> > e.g.
> >
> > $var1 = " big horse";$var2 = " small yellow";$var3 = " red 
> > hydrant";
> >
> > $theArray = array(big blue horse, small yellow bird, giant red hydrant);
> >
> > Is there a way to find out if $var1 in $theArray or $var2 etc.?
>  There's not a built in function, but it's not hard to write one:
> 
>  function partial_in_array($needle, $haystack) {
>    if (!is_array($needle)) { $needle = array($needle); }
> >>> You can reduce the above statement to the following:
> >>>
> >>> $needle = (array)$needle;
> >>>
> >>> Conversion to array creates an array with one element... the value
> >>> converted.
> >> Without raising a notice?
> > 
> > Yep.
> 
> Excellent. Don't you just love PHP.

Certainly do :)

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-11 Thread Stut

Robert Cummings wrote:

On Wed, 2007-07-11 at 15:52 +0100, Stut wrote:

Robert Cummings wrote:

On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote:

On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:

Is there a php function similar to in_array that can detect if a "partial
value" is in an array value or not:

e.g.

$var1 = " big horse";$var2 = " small yellow";$var3 = " red hydrant";

$theArray = array(big blue horse, small yellow bird, giant red hydrant);

Is there a way to find out if $var1 in $theArray or $var2 etc.?

There's not a built in function, but it's not hard to write one:

function partial_in_array($needle, $haystack) {
  if (!is_array($needle)) { $needle = array($needle); }

You can reduce the above statement to the following:

$needle = (array)$needle;

Conversion to array creates an array with one element... the value
converted.

Without raising a notice?


Yep.


Excellent. Don't you just love PHP.

-Stut

--
http://stut.net/

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



Re: [PHP] Array Question

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 15:52 +0100, Stut wrote:
> Robert Cummings wrote:
> > On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote:
> >> On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:
> >>> Is there a php function similar to in_array that can detect if a "partial
> >>> value" is in an array value or not:
> >>>
> >>> e.g.
> >>>
> >>> $var1 = " big horse";$var2 = " small yellow";$var3 = " red 
> >>> hydrant";
> >>>
> >>> $theArray = array(big blue horse, small yellow bird, giant red hydrant);
> >>>
> >>> Is there a way to find out if $var1 in $theArray or $var2 etc.?
> >> There's not a built in function, but it's not hard to write one:
> >>
> >> function partial_in_array($needle, $haystack) {
> >>   if (!is_array($needle)) { $needle = array($needle); }
> > 
> > You can reduce the above statement to the following:
> > 
> > $needle = (array)$needle;
> > 
> > Conversion to array creates an array with one element... the value
> > converted.
> 
> Without raising a notice?

Yep.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-11 Thread Stut

Robert Cummings wrote:

On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote:

On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:

Is there a php function similar to in_array that can detect if a "partial
value" is in an array value or not:

e.g.

$var1 = " big horse";$var2 = " small yellow";$var3 = " red hydrant";

$theArray = array(big blue horse, small yellow bird, giant red hydrant);

Is there a way to find out if $var1 in $theArray or $var2 etc.?

There's not a built in function, but it's not hard to write one:

function partial_in_array($needle, $haystack) {
  if (!is_array($needle)) { $needle = array($needle); }


You can reduce the above statement to the following:

$needle = (array)$needle;

Conversion to array creates an array with one element... the value
converted.


Without raising a notice?

-Stut

--
http://stut.net/

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



Re: [PHP] Array Question

2007-07-11 Thread Robert Cummings
On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote:
> On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:
> > Is there a php function similar to in_array that can detect if a "partial
> > value" is in an array value or not:
> >
> > e.g.
> >
> > $var1 = " big horse";$var2 = " small yellow";$var3 = " red hydrant";
> >
> > $theArray = array(big blue horse, small yellow bird, giant red hydrant);
> >
> > Is there a way to find out if $var1 in $theArray or $var2 etc.?
> 
> There's not a built in function, but it's not hard to write one:
> 
> function partial_in_array($needle, $haystack) {
>   if (!is_array($needle)) { $needle = array($needle); }

You can reduce the above statement to the following:

$needle = (array)$needle;

Conversion to array creates an array with one element... the value
converted.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Array Question

2007-07-11 Thread kvigor
Thanks,

I've seen the light by your code.

""Robin Vickery"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:
>> Is there a php function similar to in_array that can detect if a "partial
>> value" is in an array value or not:
>>
>> e.g.
>>
>> $var1 = " big horse";$var2 = " small yellow";$var3 = " red 
>> hydrant";
>>
>> $theArray = array(big blue horse, small yellow bird, giant red hydrant);
>>
>> Is there a way to find out if $var1 in $theArray or $var2 etc.?
>
> There's not a built in function, but it's not hard to write one:
>
> function partial_in_array($needle, $haystack) {
>  if (!is_array($needle)) { $needle = array($needle); }
>
>  $needle = array_map('preg_quote', $needle);
>
>  foreach ($needle as $pattern) {
>if (count(preg_grep("/$pattern/", $haystack)) > 0) return true;
>  }
>
>  return false;
> } 

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



Re: [PHP] Array Question

2007-07-11 Thread Robin Vickery

On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:

Is there a php function similar to in_array that can detect if a "partial
value" is in an array value or not:

e.g.

$var1 = " big horse";$var2 = " small yellow";$var3 = " red hydrant";

$theArray = array(big blue horse, small yellow bird, giant red hydrant);

Is there a way to find out if $var1 in $theArray or $var2 etc.?


There's not a built in function, but it's not hard to write one:

function partial_in_array($needle, $haystack) {
 if (!is_array($needle)) { $needle = array($needle); }

 $needle = array_map('preg_quote', $needle);

 foreach ($needle as $pattern) {
   if (count(preg_grep("/$pattern/", $haystack)) > 0) return true;
 }

 return false;
}

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



Re: [PHP] Array Question

2007-03-25 Thread Stut

[EMAIL PROTECTED] wrote:

$count=count($data->legs->leg);
$k=0;
while($k < $count)
  {

$legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];


Drop the quotes in the key...

$legrow[$data->legs->leg[$k]['legId']]=$data->legs->leg[$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];


$k++;
}

My thinking is that the $data->legs->leg[$k]['legId'] is the legId and I
might use that as a key. This however does not work.


It will work if they are all unique. If you have any duplicates they 
will overwrite previous assignments.


-Stut

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



RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
Like I said.. I'm half crocked... So I'm trying my best here... Give me some
time...

 >> > What if you put $temp = $data->legs->leg[$k]['legId']; 

Does $temp have anything in it?


Jake


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, March 25, 2007 12:09 AM
> To: Jake McHenry
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Array Question
> 
> Hi Jake
> 
> I am getting nothing at all.
> 
> Regards
> 
> Richard
> 
> >  What is the result your getting?
> >
> > Jake
> >
> >
> >> -Original Message-
> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >> Sent: Saturday, March 24, 2007 11:57 PM
> >> To: Jake McHenry
> >> Cc: php-general@lists.php.net
> >> Subject: RE: [PHP] Array Question
> >>
> >> Hi Jake
> >>
> >> I tried that and got the same result.
> >>
> >> Regards
> >>
> >> Richard
> >>
> >> > What if you put $temp = $data->legs->leg[$k]['legId'];
> >> > And then put that into $legrow[$temp];
> >> >
> >> > Do you have anything in $temp?
> >> >
> >> > Jake
> >> >
> >> >
> >> >> -Original Message-
> >> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >> >> Sent: Saturday, March 24, 2007 11:27 PM
> >> >> To: php-general@lists.php.net
> >> >> Subject: [PHP] Array Question
> >> >>
> >> >> Hi All
> >> >>
> >> >> I am having a bit of trouble with PHP arrays and would
> >> >> appreciate some help.
> >> >>
> >> >> I currently have the following piece of code
> >> >>
> >> >> $count=count($data->legs->leg);
> >> >> $k=0;
> >> >> while($k < $count)
> >> >>   {
> >> >>
> >> >> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
> >> >> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
> >> >> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
> >> >> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
> >> >> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
> >> >> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
> >> >> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
> >> >> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> >> >>
> >> >> $k++;
> >> >> }
> >> >>
> >> >> This works fine extracting the leg attributes from the
> >> legs array and
> >> >> putting the data into a new legrow array delimited by $VM.
> >> >>
> >> >> I can do a print_r($legrow); and I get the rows displayed
> >> >> correctly. I can
> >> >> also access any row by using $legrow[n] where n is the 
> key number.
> >> >>
> >> >> What I want to do is to find a way of indexing the array
> >> >> using the legId
> >> >> as the key if possible. In other words I want to extract the
> >> >> row where the
> >> >> legId has a particular value where I do not know the row key.
> >> >>
> >> >> I have been thinking that this might be possible with an
> >> >> associative array
> >> >> but my attempts to do this have not worked.
> >> >>
> >> >> What I have tried is as follows
> >> >>
> >> >> $count=count($data->legs->leg);
> >> >> $k=0;
> >> >> while($k < $count)
> >> >>   {
> >> >>
> >> >> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
> >> >> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
> >> >> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
> >> >> ta->legs->leg[$k]['equip'].$

RE: [PHP] Array Question

2007-03-24 Thread rluckhurst
Hi Jake

I am getting nothing at all.

Regards

Richard

>  What is the result your getting?
>
> Jake
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Saturday, March 24, 2007 11:57 PM
>> To: Jake McHenry
>> Cc: php-general@lists.php.net
>> Subject: RE: [PHP] Array Question
>>
>> Hi Jake
>>
>> I tried that and got the same result.
>>
>> Regards
>>
>> Richard
>>
>> > What if you put $temp = $data->legs->leg[$k]['legId'];
>> > And then put that into $legrow[$temp];
>> >
>> > Do you have anything in $temp?
>> >
>> > Jake
>> >
>> >
>> >> -Original Message-
>> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> >> Sent: Saturday, March 24, 2007 11:27 PM
>> >> To: php-general@lists.php.net
>> >> Subject: [PHP] Array Question
>> >>
>> >> Hi All
>> >>
>> >> I am having a bit of trouble with PHP arrays and would
>> >> appreciate some help.
>> >>
>> >> I currently have the following piece of code
>> >>
>> >>   $count=count($data->legs->leg);
>> >>   $k=0;
>> >>   while($k < $count)
>> >> {
>> >>
>> >> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
>> >> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
>> >> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
>> >> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
>> >> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
>> >> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
>> >> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
>> >> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
>> >>
>> >>   $k++;
>> >>   }
>> >>
>> >> This works fine extracting the leg attributes from the
>> legs array and
>> >> putting the data into a new legrow array delimited by $VM.
>> >>
>> >> I can do a print_r($legrow); and I get the rows displayed
>> >> correctly. I can
>> >> also access any row by using $legrow[n] where n is the key number.
>> >>
>> >> What I want to do is to find a way of indexing the array
>> >> using the legId
>> >> as the key if possible. In other words I want to extract the
>> >> row where the
>> >> legId has a particular value where I do not know the row key.
>> >>
>> >> I have been thinking that this might be possible with an
>> >> associative array
>> >> but my attempts to do this have not worked.
>> >>
>> >> What I have tried is as follows
>> >>
>> >> $count=count($data->legs->leg);
>> >>   $k=0;
>> >>   while($k < $count)
>> >> {
>> >>
>> >> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
>> >> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
>> >> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
>> >> ta->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM
>> >> .$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].
>> >> $VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['
>> >> meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->le
>> >> g[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
>> >>
>> >>   $k++;
>> >>   }
>> >>
>> >> My thinking is that the $data->legs->leg[$k]['legId'] is the
>> >> legId and I
>> >> might use that as a key. This however does not work.
>> >>
>> >> I would appreciate some guidance on how I might get this to work.
>> >>
>> >> Regards
>> >>
>> >> Richard Luckhurst
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >> --
>> >> No virus found in this incoming message.
>> >> Checked by AVG Free Edition.
>> >> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release
>> >> Date: 3/23/2007 3:27 PM
>> >>
>> >>
>> >
>> > --
>> > No virus found in this outgoing message.
>> > Checked by AVG Free Edition.
>> > Version: 7.5.446 / Virus Database: 268.18.17/731 - Release
>> Date: 3/23/2007
>> > 3:27 PM
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>>
>> --
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release
>> Date: 3/23/2007 3:27 PM
>>
>>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007
> 3:27 PM
>
>

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



RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
 What is the result your getting?

Jake
 

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, March 24, 2007 11:57 PM
> To: Jake McHenry
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Array Question
> 
> Hi Jake
> 
> I tried that and got the same result.
> 
> Regards
> 
> Richard
> 
> > What if you put $temp = $data->legs->leg[$k]['legId'];
> > And then put that into $legrow[$temp];
> >
> > Do you have anything in $temp?
> >
> > Jake
> >
> >
> >> -Original Message-
> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >> Sent: Saturday, March 24, 2007 11:27 PM
> >> To: php-general@lists.php.net
> >> Subject: [PHP] Array Question
> >>
> >> Hi All
> >>
> >> I am having a bit of trouble with PHP arrays and would
> >> appreciate some help.
> >>
> >> I currently have the following piece of code
> >>
> >>$count=count($data->legs->leg);
> >>$k=0;
> >>while($k < $count)
> >>  {
> >>
> >> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
> >> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
> >> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
> >> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
> >> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
> >> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
> >> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
> >> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> >>
> >>$k++;
> >>}
> >>
> >> This works fine extracting the leg attributes from the 
> legs array and
> >> putting the data into a new legrow array delimited by $VM.
> >>
> >> I can do a print_r($legrow); and I get the rows displayed
> >> correctly. I can
> >> also access any row by using $legrow[n] where n is the key number.
> >>
> >> What I want to do is to find a way of indexing the array
> >> using the legId
> >> as the key if possible. In other words I want to extract the
> >> row where the
> >> legId has a particular value where I do not know the row key.
> >>
> >> I have been thinking that this might be possible with an
> >> associative array
> >> but my attempts to do this have not worked.
> >>
> >> What I have tried is as follows
> >>
> >> $count=count($data->legs->leg);
> >>$k=0;
> >>while($k < $count)
> >>  {
> >>
> >> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
> >> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
> >> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
> >> ta->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM
> >> .$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].
> >> $VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['
> >> meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->le
> >> g[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> >>
> >>$k++;
> >>}
> >>
> >> My thinking is that the $data->legs->leg[$k]['legId'] is the
> >> legId and I
> >> might use that as a key. This however does not work.
> >>
> >> I would appreciate some guidance on how I might get this to work.
> >>
> >> Regards
> >>
> >> Richard Luckhurst
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >> --
> >> No virus found in this incoming message.
> >> Checked by AVG Free Edition.
> >> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release
> >> Date: 3/23/2007 3:27 PM
> >>
> >>
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.446 / Virus Database: 268.18.17/731 - Release 
> Date: 3/23/2007
> > 3:27 PM
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release 
> Date: 3/23/2007 3:27 PM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007
3:27 PM
 

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



RE: [PHP] Array Question

2007-03-24 Thread rluckhurst
Hi Jake

I tried that and got the same result.

Regards

Richard

> What if you put $temp = $data->legs->leg[$k]['legId'];
> And then put that into $legrow[$temp];
>
> Do you have anything in $temp?
>
> Jake
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Saturday, March 24, 2007 11:27 PM
>> To: php-general@lists.php.net
>> Subject: [PHP] Array Question
>>
>> Hi All
>>
>> I am having a bit of trouble with PHP arrays and would
>> appreciate some help.
>>
>> I currently have the following piece of code
>>
>>  $count=count($data->legs->leg);
>>  $k=0;
>>  while($k < $count)
>>{
>>
>> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
>> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
>> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
>> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
>> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
>> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
>> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
>> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
>>
>>  $k++;
>>  }
>>
>> This works fine extracting the leg attributes from the legs array and
>> putting the data into a new legrow array delimited by $VM.
>>
>> I can do a print_r($legrow); and I get the rows displayed
>> correctly. I can
>> also access any row by using $legrow[n] where n is the key number.
>>
>> What I want to do is to find a way of indexing the array
>> using the legId
>> as the key if possible. In other words I want to extract the
>> row where the
>> legId has a particular value where I do not know the row key.
>>
>> I have been thinking that this might be possible with an
>> associative array
>> but my attempts to do this have not worked.
>>
>> What I have tried is as follows
>>
>> $count=count($data->legs->leg);
>>  $k=0;
>>  while($k < $count)
>>{
>>
>> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
>> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
>> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
>> ta->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM
>> .$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].
>> $VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['
>> meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->le
>> g[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
>>
>>  $k++;
>>  }
>>
>> My thinking is that the $data->legs->leg[$k]['legId'] is the
>> legId and I
>> might use that as a key. This however does not work.
>>
>> I would appreciate some guidance on how I might get this to work.
>>
>> Regards
>>
>> Richard Luckhurst
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> --
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release
>> Date: 3/23/2007 3:27 PM
>>
>>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007
> 3:27 PM
>
>
> --
> 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] Array Question

2007-03-24 Thread rluckhurst
Hi Jake

Thanks for the answer.

That is what I had in my example that did not work.

I had tried that and then wondered how I might access that key.

I have tried $legrow["number"];

where number is a value I know to be one of the legId's. Is this correct?

Regards

Richard


> $legrow["$data->legs->leg[$k]['legId']"]
>
> ?? See if that works...
>
> Jake
>
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Saturday, March 24, 2007 11:27 PM
>> To: php-general@lists.php.net
>> Subject: [PHP] Array Question
>>
>> Hi All
>>
>> I am having a bit of trouble with PHP arrays and would
>> appreciate some help.
>>
>> I currently have the following piece of code
>>
>>  $count=count($data->legs->leg);
>>  $k=0;
>>  while($k < $count)
>>{
>>
>> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
>> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
>> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
>> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
>> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
>> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
>> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
>> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
>>
>>  $k++;
>>  }
>>
>> This works fine extracting the leg attributes from the legs array and
>> putting the data into a new legrow array delimited by $VM.
>>
>> I can do a print_r($legrow); and I get the rows displayed
>> correctly. I can
>> also access any row by using $legrow[n] where n is the key number.
>>
>> What I want to do is to find a way of indexing the array
>> using the legId
>> as the key if possible. In other words I want to extract the
>> row where the
>> legId has a particular value where I do not know the row key.
>>
>> I have been thinking that this might be possible with an
>> associative array
>> but my attempts to do this have not worked.
>>
>> What I have tried is as follows
>>
>> $count=count($data->legs->leg);
>>  $k=0;
>>  while($k < $count)
>>{
>>
>> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
>> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
>> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
>> ta->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM
>> .$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].
>> $VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['
>> meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->le
>> g[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
>>
>>  $k++;
>>  }
>>
>> My thinking is that the $data->legs->leg[$k]['legId'] is the
>> legId and I
>> might use that as a key. This however does not work.
>>
>> I would appreciate some guidance on how I might get this to work.
>>
>> Regards
>>
>> Richard Luckhurst
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> --
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release
>> Date: 3/23/2007 3:27 PM
>>
>>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007
> 3:27 PM
>
>

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



RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
What if you put $temp = $data->legs->leg[$k]['legId'];
And then put that into $legrow[$temp];

Do you have anything in $temp?

Jake


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, March 24, 2007 11:27 PM
> To: php-general@lists.php.net
> Subject: [PHP] Array Question
> 
> Hi All
> 
> I am having a bit of trouble with PHP arrays and would 
> appreciate some help.
> 
> I currently have the following piece of code
> 
>   $count=count($data->legs->leg);
>   $k=0;
>   while($k < $count)
> {
>   
> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> 
>   $k++;
>   }
> 
> This works fine extracting the leg attributes from the legs array and
> putting the data into a new legrow array delimited by $VM.
> 
> I can do a print_r($legrow); and I get the rows displayed 
> correctly. I can
> also access any row by using $legrow[n] where n is the key number.
> 
> What I want to do is to find a way of indexing the array 
> using the legId
> as the key if possible. In other words I want to extract the 
> row where the
> legId has a particular value where I do not know the row key.
> 
> I have been thinking that this might be possible with an 
> associative array
> but my attempts to do this have not worked.
> 
> What I have tried is as follows
> 
> $count=count($data->legs->leg);
>   $k=0;
>   while($k < $count)
> {
>   
> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
> ta->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM
> .$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].
> $VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['
> meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->le
> g[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> 
>   $k++;
>   }
> 
> My thinking is that the $data->legs->leg[$k]['legId'] is the 
> legId and I
> might use that as a key. This however does not work.
> 
> I would appreciate some guidance on how I might get this to work.
> 
> Regards
> 
> Richard Luckhurst
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release 
> Date: 3/23/2007 3:27 PM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007
3:27 PM
 

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



RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
$legrow["$data->legs->leg[$k]['legId']"]

?? See if that works...

Jake



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, March 24, 2007 11:27 PM
> To: php-general@lists.php.net
> Subject: [PHP] Array Question
> 
> Hi All
> 
> I am having a bit of trouble with PHP arrays and would 
> appreciate some help.
> 
> I currently have the following piece of code
> 
>   $count=count($data->legs->leg);
>   $k=0;
>   while($k < $count)
> {
>   
> $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->legs->leg
> [$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->
> legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$V
> M.$data->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'
> ].$VM.$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['mil
> es'].$VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[
> $k]['meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->leg
> s->leg[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> 
>   $k++;
>   }
> 
> This works fine extracting the leg attributes from the legs array and
> putting the data into a new legrow array delimited by $VM.
> 
> I can do a print_r($legrow); and I get the rows displayed 
> correctly. I can
> also access any row by using $legrow[n] where n is the key number.
> 
> What I want to do is to find a way of indexing the array 
> using the legId
> as the key if possible. In other words I want to extract the 
> row where the
> legId has a particular value where I do not know the row key.
> 
> I have been thinking that this might be possible with an 
> associative array
> but my attempts to do this have not worked.
> 
> What I have tried is as follows
> 
> $count=count($data->legs->leg);
>   $k=0;
>   while($k < $count)
> {
>   
> $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k][
> 'depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs-
> >leg[$k]['dstApt'].$VM.$data->legs->leg[$k]['arrTime'].$VM.$da
> ta->legs->leg[$k]['equip'].$VM.$data->legs->leg[$k]['fNo'].$VM
> .$data->legs->leg[$k]['cr'].$VM.$data->legs->leg[$k]['miles'].
> $VM.$data->legs->leg[$k]['elapsed'].$VM.$data->legs->leg[$k]['
> meals'].$VM.$data->legs->leg[$k]['smoker'].$VM.$data->legs->le
> g[$k]['stops'].$VM.$data->legs->leg[$k]['eticket'];
> 
>   $k++;
>   }
> 
> My thinking is that the $data->legs->leg[$k]['legId'] is the 
> legId and I
> might use that as a key. This however does not work.
> 
> I would appreciate some guidance on how I might get this to work.
> 
> Regards
> 
> Richard Luckhurst
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/731 - Release 
> Date: 3/23/2007 3:27 PM
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007
3:27 PM
 

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



Re: [PHP] Array question

2007-02-27 Thread Gerry D

Mike,

See entire function under topic "Array question - maybe UTF?"...

I am trying to change accented characters to their equivalent without accents.

And yes, the arrays look fine after var_dump()...

Gerry

On 2/27/07, Ford, Mike <[EMAIL PROTECTED]> wrote:

On 27 February 2007 04:23, Gerry D wrote:

> I have a question on how to retrieve the value that corresponds to a
> key in an array.
>
> $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');
>
>   $key = array_search($c, $fruit);
>   if ( $key === FALSE )
>   $n = $c;
>   else
>   {
>   $n = $fruit[$key];  // how to get the value???
>   }
>
> the array_search works ok, but how do I get the value?
>
> all I get back is 'a' or 'b', not 'apple' or 'banana'...

Please show a little more code, as it looks to me as though this should work 
how you think it should.

Specifically:  how do we know what is in $c? how do you know the array_search 
works? how do you know $n is only getting 'a', 'b', or 'c'?  (Hint: var_dump() 
is your friend!)


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



RE: [PHP] Array question

2007-02-27 Thread Ford, Mike
On 27 February 2007 04:23, Gerry D wrote:

> I have a question on how to retrieve the value that corresponds to a
> key in an array. 
> 
> $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');
> 
>   $key = array_search($c, $fruit);
>   if ( $key === FALSE )
>   $n = $c;
>   else
>   {
>   $n = $fruit[$key];  // how to get the value???
>   }
> 
> the array_search works ok, but how do I get the value?
> 
> all I get back is 'a' or 'b', not 'apple' or 'banana'...

Please show a little more code, as it looks to me as though this should work 
how you think it should.

Specifically:  how do we know what is in $c? how do you know the array_search 
works? how do you know $n is only getting 'a', 'b', or 'c'?  (Hint: var_dump() 
is your friend!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Array question

2007-02-26 Thread Hap-Hang Yu

Try:

$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');
$search = 'apple';

foreach($fruit as $key => $val) {
 if ($val == $search) {
echo "$search found: array key is $key, value is $val";
 }
}

2007/2/27, Gerry D <[EMAIL PROTECTED]>:

I have a question on how to retrieve the value that corresponds to a
key in an array.

$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');

$key = array_search($c, $fruit);
if ( $key === FALSE )
$n = $c;
else
{
$n = $fruit[$key];  // how to get the value???
}

the array_search works ok, but how do I get the value?

all I get back is 'a' or 'b', not 'apple' or 'banana'...

TIA

Gerry

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





--
--
Hap-Hang Yu, Jay

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



[PHP] Re: php array question

2004-11-01 Thread Victor C.
Hi Ben,
I tried your portion of code and find out what was wrong... Apparently I
used & in adding order to the array and that was messing things up...
Everything is working now.
Thanks for all the help


"Victor C." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I did a print_r(array_values)before calling the codes that had errors
in
> it.. the following content is contained in $this->orders;
>
> Array ( [0] => order Object ( [UserObject] => user Object ( [UserID] =>
> E2401 [Pass] => [IsValid] => 1 [UserType] => AT [fonthtml] => [footerfile]
> => resources/footer.php [headerfile] => resources/header.php [Email] =>
> [EMAIL PROTECTED] [FirstName] => Dennis [LastName] => 5
> [Salutation] => [Phone] => 123-456-7890 [Fax] => 321-123-4567 [Address1]
=>
> 555 Testing Avenue [Address2] => Test 200 [City] => Orlando [State] => FL
> [Zip] => 12345 [DisplayName] => 52II Rfc [Region] => WEST [OSJ] => 1
> [Series7] => 1 [OSJAddress1] => Changed 9:55 Am [OSJAddress2] => [OSJCity]
> => Des Moines [OSJState] => IA [OSJZip] =>  [OSJPhone] => 43143431214
> [existsindb] => 1 [firsttime] => 1 ) [OrderID] => 392 [CartID] => 90
> [TemplateID] => 1 [UserID] => E2401 [completed] => 1 [ordername] => 4312
> [existsindb] => 1 [cost] => 3665.2 [totalcopies] => [directmailquantity]
=>
> [directshippingmethod] => [overprintquantity] => 4312
> [overprintshippingmethod] => [rushoption] => Standard [dl1000instancefile]
> =>
> 0|C:/Inetpub/wwwroot/printsite/|0|C:/Inetpub/wwwroot/printsite/|0|0|Dennis
> J. Cunningham II Rfc|Enter your company:|123-456-7890|321-123-4567|Changed
> 9:55 Am, Des Moines, IA,
>
|C:/Inetpub/wwwroot/printsite/|FALL|2004|C:/Inetpub/wwwroot/printsite/ae
> gonresources/stockimages/highres/ISI_logo.jpg|Securities offered through
> InterSecurities, Inc. Member NASD, SIPC and Registered Investment
> Advisor|Changed 9:55 Am, Des Moines, IA,
|C:/Inetpub/wwwroot/printsite/
> [flashvars] => 0||0||0|0|341431|Enter your
> company:|123-456-7890|321-123-4567|Changed 9:55 Am, Des Moines, IA,
>
||FALL|2004|http://69.44.155.247/printsite/aegonresources/stockimages/lo
> wres/ISI_logo.jpg|Securities offered through InterSecurities, Inc. Member
> NASD, SIPC and Registered Investment Advisor|Changed 9:55 Am, Des Moines,
> IA, | [dbname] => [dbpath] => [age] => [zip] => [gender] => [income]
=>
> [home] => [homevalue] => [length] => [children] => [childrenAge] =>
> [marital] => [networth] => [stock] => [listquantity] => )
>
> [1] => order Object ( [UserObject] => user Object ( [UserID] => E2401
[Pass]
> => [IsValid] => 1 [UserType] => AT [fonthtml] => [footerfile] =>
> resources/footer.php [headerfile] => resources/header.php [Email] =>
> [EMAIL PROTECTED] [FirstName] => Dennis [LastName] => Cunningham
> [Salutation] => [Phone] => 123-456-7890 [Fax] => 321-123-4567 [Address1]
=>
> 555 Testing Avenue [Address2] => Test 200 [City] => Orlando [State] => FL
> [Zip] => 12345 [DisplayName] => Dennis J. Cunningham II Rfc [Region] =>
WEST
> [OSJ] => 1 [Series7] => 1 [OSJAddress1] => Changed 9:55 Am [OSJAddress2]
=>
> [OSJCity] => Des Moines [OSJState] => IA [OSJZip] =>  [OSJPhone] =>
> 43143431214 [existsindb] => 1 [firsttime] => 1 ) [OrderID] => 392 [CartID]
> => 90 [TemplateID] => 1 [UserID] => E2401 [completed] => 1 [ordername] =>
> 4312 [existsindb] => 1 [cost] => 3665.2 [totalcopies] =>
> [directmailquantity] => [directshippingmethod] => [overprintquantity] =>
> 4312 [overprintshippingmethod] => [rushoption] => Standard
> [dl1000instancefile] =>
> 0|C:/Inetpub/wwwroot/printsite/|0|C:/Inetpub/wwwroot/printsite/|0|0|Dennis
> J. Cunningham II Rfc|Enter your company:|123-456-7890|321-123-4567|Changed
> 9:55 Am, Des Moines, IA,
>
|C:/Inetpub/wwwroot/printsite/|FALL|2004|C:/Inetpub/wwwroot/printsite/ae
> gonresources/stockimages/highres/ISI_logo.jpg|Securities offered through
> InterSecurities, Inc. Member NASD, SIPC and Registered Investment
> Advisor|Changed 9:55 Am, Des Moines, IA,
|C:/Inetpub/wwwroot/printsite/
> [flashvars] => 0||0||0|0|432141 II Rfc|Enter your
> company:|123-456-7890|321-123-4567|Changed 9:55 Am, Des Moines, IA,
>
||FALL|2004|http://69.44.155.247/printsite/aegonresources/stockimages/lo
> wres/ISI_logo.jpg|Securities offered through InterSecurities, Inc. Member
> NASD, SIPC and Registered Investment Advisor|Changed 9:55 Am, Des Moines,
> IA, | [dbname] => [dbpath] => [age] => [zip] => [gender] => [income]
=>
> [home] => [homevalue] => [length] => [children] => [childrenAge] =>
> [marital] => [networth] => [stock] => [listquantity] => ) )
1Object<--value.
>
>
> 391<--OrderID.
> 392<--going crazy
> Object<--value.
> 392<--OrderID.
> 392<--going crazy
>
>
>
> "Ben Ramsey" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Ben Ramsey wrote:
> > > Victor C. wrote:
> > >
> > >> $OrderObject =$this->orders[$OrderID=>$value];
> > >
> > >
> > > This line is confusing. $OrderID=>$value is either a typo or is just
> > > plain wrong. It looks like what i

[PHP] Re: php array question

2004-11-01 Thread Ben Ramsey
Victor C. wrote:
I did a print_r(array_values)before calling the codes that had errors in
it.. the following content is contained in $this->orders;
Aaaghh. Can you give that to us in pre-formatted text, rather than 
copying and pasting it from the browser. My eyes are going everywhere 
trying to make sense of it. View the source of the page and grab it from 
there, please. :-)

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: php array question

2004-11-01 Thread Victor C.
I did a print_r(array_values)before calling the codes that had errors in
it.. the following content is contained in $this->orders;

Array ( [0] => order Object ( [UserObject] => user Object ( [UserID] =>
E2401 [Pass] => [IsValid] => 1 [UserType] => AT [fonthtml] => [footerfile]
=> resources/footer.php [headerfile] => resources/header.php [Email] =>
[EMAIL PROTECTED] [FirstName] => Dennis [LastName] => 5
[Salutation] => [Phone] => 123-456-7890 [Fax] => 321-123-4567 [Address1] =>
555 Testing Avenue [Address2] => Test 200 [City] => Orlando [State] => FL
[Zip] => 12345 [DisplayName] => 52II Rfc [Region] => WEST [OSJ] => 1
[Series7] => 1 [OSJAddress1] => Changed 9:55 Am [OSJAddress2] => [OSJCity]
=> Des Moines [OSJState] => IA [OSJZip] =>  [OSJPhone] => 43143431214
[existsindb] => 1 [firsttime] => 1 ) [OrderID] => 392 [CartID] => 90
[TemplateID] => 1 [UserID] => E2401 [completed] => 1 [ordername] => 4312
[existsindb] => 1 [cost] => 3665.2 [totalcopies] => [directmailquantity] =>
[directshippingmethod] => [overprintquantity] => 4312
[overprintshippingmethod] => [rushoption] => Standard [dl1000instancefile]
=>
0|C:/Inetpub/wwwroot/printsite/|0|C:/Inetpub/wwwroot/printsite/|0|0|Dennis
J. Cunningham II Rfc|Enter your company:|123-456-7890|321-123-4567|Changed
9:55 Am, Des Moines, IA,
|C:/Inetpub/wwwroot/printsite/|FALL|2004|C:/Inetpub/wwwroot/printsite/ae
gonresources/stockimages/highres/ISI_logo.jpg|Securities offered through
InterSecurities, Inc. Member NASD, SIPC and Registered Investment
Advisor|Changed 9:55 Am, Des Moines, IA, |C:/Inetpub/wwwroot/printsite/
[flashvars] => 0||0||0|0|341431|Enter your
company:|123-456-7890|321-123-4567|Changed 9:55 Am, Des Moines, IA,
||FALL|2004|http://69.44.155.247/printsite/aegonresources/stockimages/lo
wres/ISI_logo.jpg|Securities offered through InterSecurities, Inc. Member
NASD, SIPC and Registered Investment Advisor|Changed 9:55 Am, Des Moines,
IA, | [dbname] => [dbpath] => [age] => [zip] => [gender] => [income] =>
[home] => [homevalue] => [length] => [children] => [childrenAge] =>
[marital] => [networth] => [stock] => [listquantity] => )

[1] => order Object ( [UserObject] => user Object ( [UserID] => E2401 [Pass]
=> [IsValid] => 1 [UserType] => AT [fonthtml] => [footerfile] =>
resources/footer.php [headerfile] => resources/header.php [Email] =>
[EMAIL PROTECTED] [FirstName] => Dennis [LastName] => Cunningham
[Salutation] => [Phone] => 123-456-7890 [Fax] => 321-123-4567 [Address1] =>
555 Testing Avenue [Address2] => Test 200 [City] => Orlando [State] => FL
[Zip] => 12345 [DisplayName] => Dennis J. Cunningham II Rfc [Region] => WEST
[OSJ] => 1 [Series7] => 1 [OSJAddress1] => Changed 9:55 Am [OSJAddress2] =>
[OSJCity] => Des Moines [OSJState] => IA [OSJZip] =>  [OSJPhone] =>
43143431214 [existsindb] => 1 [firsttime] => 1 ) [OrderID] => 392 [CartID]
=> 90 [TemplateID] => 1 [UserID] => E2401 [completed] => 1 [ordername] =>
4312 [existsindb] => 1 [cost] => 3665.2 [totalcopies] =>
[directmailquantity] => [directshippingmethod] => [overprintquantity] =>
4312 [overprintshippingmethod] => [rushoption] => Standard
[dl1000instancefile] =>
0|C:/Inetpub/wwwroot/printsite/|0|C:/Inetpub/wwwroot/printsite/|0|0|Dennis
J. Cunningham II Rfc|Enter your company:|123-456-7890|321-123-4567|Changed
9:55 Am, Des Moines, IA,
|C:/Inetpub/wwwroot/printsite/|FALL|2004|C:/Inetpub/wwwroot/printsite/ae
gonresources/stockimages/highres/ISI_logo.jpg|Securities offered through
InterSecurities, Inc. Member NASD, SIPC and Registered Investment
Advisor|Changed 9:55 Am, Des Moines, IA, |C:/Inetpub/wwwroot/printsite/
[flashvars] => 0||0||0|0|432141 II Rfc|Enter your
company:|123-456-7890|321-123-4567|Changed 9:55 Am, Des Moines, IA,
||FALL|2004|http://69.44.155.247/printsite/aegonresources/stockimages/lo
wres/ISI_logo.jpg|Securities offered through InterSecurities, Inc. Member
NASD, SIPC and Registered Investment Advisor|Changed 9:55 Am, Des Moines,
IA, | [dbname] => [dbpath] => [age] => [zip] => [gender] => [income] =>
[home] => [homevalue] => [length] => [children] => [childrenAge] =>
[marital] => [networth] => [stock] => [listquantity] => ) ) 1Object<--value.


391<--OrderID.
392<--going crazy
Object<--value.
392<--OrderID.
392<--going crazy



"Ben Ramsey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ben Ramsey wrote:
> > Victor C. wrote:
> >
> >> $OrderObject =$this->orders[$OrderID=>$value];
> >
> >
> > This line is confusing. $OrderID=>$value is either a typo or is just
> > plain wrong. It looks like what it's meant to say is:
> >
> > $OrderObject = $this->orders[$OrderID];
> >
> > But this will just set $OrderObject equal to $value, so you should just
> > use:
> >
> > $OrderObject = $value;
> >
> > Try that and see if it works.
> >
>
> Nevermind. I read that wrong. $this->orders is an array of objects, like
> you said, which I glanced over too quickly.
>
> My statement above still holds, though. $this->orders[$OrderID=>$value]
> still app

[PHP] Re: php array question

2004-11-01 Thread Ben Ramsey
Ben Ramsey wrote:
Victor C. wrote:
$OrderObject =$this->orders[$OrderID=>$value];

This line is confusing. $OrderID=>$value is either a typo or is just 
plain wrong. It looks like what it's meant to say is:

$OrderObject = $this->orders[$OrderID];
But this will just set $OrderObject equal to $value, so you should just 
use:

$OrderObject = $value;
Try that and see if it works.
Nevermind. I read that wrong. $this->orders is an array of objects, like 
you said, which I glanced over too quickly.

My statement above still holds, though. $this->orders[$OrderID=>$value] 
still appears to be a typo to me. It might supposed to be:

$OrderObject = $this->orders[$OrderID]
which will return the order object at $OrderID location in the array 
($OrderID being the array key).

Then, $OrderObject->OrderID should work properly.
However, I would think that
echo $OrderObject->OrderID;
should produce the same results as
echo $OrderID;
But I could be wrong since I'm not exactly sure how the order object looks.
Perhaps doing a var_dump on the $this->orders would help us out?
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: php array question

2004-11-01 Thread Victor C.
But why would the this line generate different OrderID on lines 1 and 3?
"Ben Ramsey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Victor C. wrote:
> > $OrderObject =$this->orders[$OrderID=>$value];
>
> This line is confusing. $OrderID=>$value is either a typo or is just
> plain wrong. It looks like what it's meant to say is:
>
> $OrderObject = $this->orders[$OrderID];
>
> But this will just set $OrderObject equal to $value, so you should just
use:
>
> $OrderObject = $value;
>
> Try that and see if it works.
>
> --
> Ben Ramsey
> Zend Certified Engineer
> http://benramsey.com
>
> ---
> Atlanta PHP - http://www.atlphp.org/
> The Southeast's premier PHP community.
> ---

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



[PHP] Re: php array question

2004-11-01 Thread Ben Ramsey
Victor C. wrote:
$OrderObject =$this->orders[$OrderID=>$value];
This line is confusing. $OrderID=>$value is either a typo or is just 
plain wrong. It looks like what it's meant to say is:

$OrderObject = $this->orders[$OrderID];
But this will just set $OrderObject equal to $value, so you should just use:
$OrderObject = $value;
Try that and see if it works.
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Array Question

2004-02-28 Thread Michal Migurski
>I would like to search an array to see if the value of the variable $url
>exists in this array.  The array would look like:

in_array()

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Array question

2003-09-27 Thread Cristian Lavaque
http://www.php.net/manual/en/language.types.array.php

If you mean having an array inside an array, of course . There you have an array inside another
one, 'data' will be here $var['0']['0'].

If you meant using an array item as the key in another array,
then you do it as with a normal var .
Remember not to quote $arr2 just as you wouldn't a quote a var
when using it as the key.

In your question you're mixing both:
> Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

Unquote 'aCheckBoxes[$iIndex]['sName']' and put the $ sign in
front:
$paArgs[$aCheckBoxes[$iIndex]['sName']]

I hope this helped.

Cristian



Robin Kopetzky wrote:
> Good morning all!!
>
> Can you nest an array within an array??
>
> Example: $paArgs['aCheckBoxes[$iIndex]['sName']']
>
> Thank you in advance.
>
> Robin 'Sparky' Kopetzky
> Black Mesa Computers/Internet Service
> Grants, NM 87020

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



Re: [PHP] Array question

2003-09-27 Thread Jackson Miller
On Saturday 27 September 2003 11:18, Robin Kopetzky wrote:
> Good morning all!!
>
> Can you nest an array within an array??
>
> Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

Yes, but like this
$array['aCheckBoxes'][] = $iIndex['sName']

This means:
$array is an array
aCheckBoxes is a item in $array
aCheckBoxes is also an array
$iIndex is an item in the aCheckBoxes array
$iIndex is an array.

Hope this helps.

-Jackson


>
> Thank you in advance.
>
> Robin 'Sparky' Kopetzky
> Black Mesa Computers/Internet Service
> Grants, NM 87020

-- 
jackson miller
 
cold feet creative
615.321.3300 / 800.595.4401
[EMAIL PROTECTED]
 
 
cold feet presents Emma
the world's easiest email marketing
Learn more @  http://www.myemma.com

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



Re: [PHP] Array question

2003-09-27 Thread Robert Cummings
On Sat, 2003-09-27 at 12:18, Robin Kopetzky wrote:
> Good morning all!!
> 
> Can you nest an array within an array??
> 
> Example: $paArgs['aCheckBoxes[$iIndex]['sName']']

You mean can you retrieve an array entry by giving a key defined by a
value in another array? To do so remove the outer quotes in your above
statement and add a $ to the interior array.

Example: $paArgs[$aCheckBoxes[$iIndex]['sName']]

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Array Question

2003-07-28 Thread Jim Lucas
Try this.

$companyname[] = $row['company'];


Jim Lucas
- Original Message - 
From: "Pushpinder Singh Garcha" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 28, 2003 10:16 AM
Subject: [PHP] Array Question


hello everyone,

  I am trying to store one of the fields of the resultset into an array  
as I display the results.

   while ($row = mysql_fetch_array($result1)) {

 // Alternate the bgcolor of each row for visibility
 ($even % 2) == 0 ? $bgcolor = "#EFEFEF" : $bgcolor =  
"#ee";
 $even = $even + 1;

 // print the actual row
echo   "
   $row[company]
   $row[name_1]
   $row[phone_1]
  $row[city]
  $row[url]
   $row[email_1]
  --Link--
   ";

// try to store the name of the company in an array called companyname

$companyname = array($row['company']);

 // try to register the variable

 $_SESSION['link'] = $companyname;
   //$_SESSION['link'] = $row[company];

 } // end while



I am trying to store the variable $row['company'] into a array called  
companyname[], so that I am able to register it as a session variable  
and use it on subsequent pages. I keep getting errors and am not able  
to store the values in array $row['company'] . I would appreciate if  
someone could throw some light on this.

Thanks in advance.
--Pushpinder



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



Re: [PHP] ARRAY QUESTION

2003-07-24 Thread Curt Zirzow
* Thus wrote Dale Hersh ([EMAIL PROTECTED]):
> I have a question regarding the count function. Here goes:
> 
> Lets pretend I have this array called myStuff. If I add two elements to
> myStuff and call the count function, I will get a result of 2. My question
> is how do I re-initialize the array after adding elements so when I call the
> count function on the array, I get a result of 0.


unset($myStuff);
or
$myStuff = array();


I usually prefer the empty array method vs. using unset for coding
things like:

$arr = array();
func_to_mod_array($arr);

foreach($arr as $key => val) {
  //
}

If I used the unset function I'd have to check to see if the
variable is set or not.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



RE: [PHP] ARRAY QUESTION

2003-07-24 Thread Chris W. Parker
Dale Hersh 
on Thursday, July 24, 2003 12:41 PM said:

> Lets pretend I have this array called myStuff. If I add two elements
> to myStuff and call the count function, I will get a result of 2. My
> question is how do I re-initialize the array after adding elements so
> when I call the count function on the array, I get a result of 0.

unset($myStuff);

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



RE: [PHP] ARRAY QUESTION

2003-07-24 Thread Jay Blanchard
[snip]
Lets pretend I have this array called myStuff. If I add two elements to
myStuff and call the count function, I will get a result of 2. My
question
is how do I re-initialize the array after adding elements so when I call
the
count function on the array, I get a result of 0.
[/snip]

If you add elements to the array the count will never be 0. What exactly
are you after?

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



Re: [PHP] array question

2003-05-30 Thread Randy Johnson
I found this in the manual user comments and it worked great

mysql_data_seek($result,0);

Randy
- Original Message - 
From: "Randy Johnson" <[EMAIL PROTECTED]>
To: "Brian Dunning" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, May 29, 2003 10:14 PM
Subject: [PHP] array question


> How do I access the data in $query_data after I go through the while loop,
> here is an example
>
> $result=mysql_query($query,$link);
> while ($query_data=mysql_fetch_array($result) )
> {
>$var1=$query_data["var1"];
>$var1=$query_data["var1"];
> }
>
> after the while is done,   How do I access the data in query data again .
I
> perform calculations the first time and the second time I need to display
> the rows on the screen.
>
>
> Randy
>
>
>
>
> -- 
> 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] Array Question

2003-04-01 Thread Rob Adams
Creating an array that holds the 11 combined records from the two tables,
and sorting the array according to date:  (This depends on what type your
using to store dates in MySQL, and that the exact date is unique for each
record across both tables.  If the date isn't unique, it requires a little
modification to the assignment in the array and the display later on.)

date_field_name] = $tmp;
mysql_free_result($res);
// repeat previous 4 lines for table2.

sort($tbl_arr);

foreach($tbl_arr as $dt => $record)
  echo date(" -- date format -- ", $dt) . "$record->field1 -
$record->field2 - etc...";
?>

  -- Rob

"Mark McCulligh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I can't link the two tables at all.
>
> I need to loop through one displaying its information, then loop through
the
> other table displaying its information.  For if I have 5 records in table
A
> and 6 records in table B, I get 11 records total. Each table only has 4-5
> fields and they exist in both table. The two tables have the same
structure
> minus one field.  The two tables should have been one table but I didn't
> design the database but have to make it work. Using I would use a view to
> make one master table then order it by the common date field. But MySQL
> doesn't have view let.
>
> The reason I can't just display one table after the other is that I need
the
> PHP page to have the results ordered by the common date field.
>
> I can't link the two tables together in the SQL.
>
> Mark.
>
>



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



Re: [PHP] Array Question

2003-04-01 Thread Tim Burden
If you added a dummy field in the table that is minus one field, you might
use the merge table, but I honestly have no idea whether this would be more
or less efficient than sorting arrays in memory. Guess that would depend on
the sizes of the tables and the number of records you'll be returning.

http://www.mysql.com/doc/en/MERGE.html

- Original Message -
From: "Mark McCulligh" <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 01, 2003 12:33 PM
Subject: Re: [PHP] Array Question


> I have looked at the different JOINs but I can't link any fields together.
> There is no relationship between the tables. The two table are basically
the
> same table. But the DBA didn't make them one like he should have.
>
> Mark.
>
>
> "Skate" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> look into things like JOIN and SORT BY in MySQL, they're quicker and more
> efficient than PHP for doing DB stuff (so i'm told)
>
> took me awhile to get my head around JOIN, but once you've got it, you'll
> never be without it ;)
>
>
> "Mark McCulligh" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I have two tables that I want to display together as if they were one
> table
> > and order them by a common date field.
> >
> > Because I am using MySQL I can't use the usually way I would do this.
> Create
> > a store procedure or view.
> >
> > I was thinking of creating two separate queries in PHP then loading the
> data
> > into one Array. In short loop though both tables copying the records
into
> an
> > array.
> >
> > Then I was going to sort the Array my a common date field. Then of
course
> > loop through printing the Array.
> >
> > My question is: Is this the best way to do this or is there another way.
> > Also how can you sort an Array by one date field.
> >
> > Any ideas on how to do link two tables together and sort my a common dat
e
> > field.
> >
> > Thanks,
> > Mark.
> >
> >
> >
> > --
> > 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] Array Question

2003-04-01 Thread Mark McCulligh
I have looked at the different JOINs but I can't link any fields together.
There is no relationship between the tables. The two table are basically the
same table. But the DBA didn't make them one like he should have.

Mark.


"Skate" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
look into things like JOIN and SORT BY in MySQL, they're quicker and more
efficient than PHP for doing DB stuff (so i'm told)

took me awhile to get my head around JOIN, but once you've got it, you'll
never be without it ;)


"Mark McCulligh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have two tables that I want to display together as if they were one
table
> and order them by a common date field.
>
> Because I am using MySQL I can't use the usually way I would do this.
Create
> a store procedure or view.
>
> I was thinking of creating two separate queries in PHP then loading the
data
> into one Array. In short loop though both tables copying the records into
an
> array.
>
> Then I was going to sort the Array my a common date field. Then of course
> loop through printing the Array.
>
> My question is: Is this the best way to do this or is there another way.
> Also how can you sort an Array by one date field.
>
> Any ideas on how to do link two tables together and sort my a common date
> field.
>
> Thanks,
> Mark.
>
>
>
> --
> 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] Array Question

2003-04-01 Thread Mark McCulligh
I can't link the two tables at all.

I need to loop through one displaying its information, then loop through the
other table displaying its information.  For if I have 5 records in table A
and 6 records in table B, I get 11 records total. Each table only has 4-5
fields and they exist in both table. The two tables have the same structure
minus one field.  The two tables should have been one table but I didn't
design the database but have to make it work. Using I would use a view to
make one master table then order it by the common date field. But MySQL
doesn't have view let.

The reason I can't just display one table after the other is that I need the
PHP page to have the results ordered by the common date field.

I can't link the two tables together in the SQL.

Mark.



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



Re: [PHP] Array Question

2003-04-01 Thread Chris Hayes
At 18:58 1-4-03, you wrote:
I have two tables that I want to display together as if they were one table
and order them by a common date field.
Because I am using MySQL I can't use the usually way I would do this. Create
a store procedure or view.
Does every row in tableA has a sibling row in tableB and vice versa, and is 
there some field that could combine them? For instance this date field, is 
it unique (one entry for every date) ?

If the answer is yes to both:

$query="SELECT title, text, date FROM tableA as A, tableB as B WHERE 
A.date=B.date ORDER BY date"

Now (AFAIK) if table A has 2 entries on april1 and table B has 3 entries on 
april1, you would get 2x3=6 resulting rows with all possible combinations.
You could also link with any combination of fieldnames, like
  WHERE A.category=B.the_category
  WHERE A.category=B.catID

If that does not work for you look up the array sort functions. Best 
also do a search in the webpage from this list (see ww.php.net -> 
emaillists -> archive), look for array and sort.



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


Re: [PHP] Array Question

2003-04-01 Thread skate
look into things like JOIN and SORT BY in MySQL, they're quicker and more efficient 
than PHP for doing DB stuff (so i'm told)

took me awhile to get my head around JOIN, but once you've got it, you'll never be 
without it ;)


"Mark McCulligh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I have two tables that I want to display together as if they were one table
> and order them by a common date field.
> 
> Because I am using MySQL I can't use the usually way I would do this. Create
> a store procedure or view.
> 
> I was thinking of creating two separate queries in PHP then loading the data
> into one Array. In short loop though both tables copying the records into an
> array.
> 
> Then I was going to sort the Array my a common date field. Then of course
> loop through printing the Array.
> 
> My question is: Is this the best way to do this or is there another way.
> Also how can you sort an Array by one date field.
> 
> Any ideas on how to do link two tables together and sort my a common date
> field.
> 
> Thanks,
> Mark.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

RE: [PHP] array question

2003-03-10 Thread Ford, Mike [LSS]
> -Original Message-
> From: Jason Wong [mailto:[EMAIL PROTECTED]
> Sent: 10 March 2003 15:35
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] array question
> 
> 
> On Monday 10 March 2003 21:13, Diana Castillo wrote:
> > If I sort an array, and now the keys are not in numerical 
> order, how can I
> > get the key of the first element?
> > If I do array_shift I get the first element but I want that key.
> 
> Not very elegant -- there must be a better way?
> 
> foreach ($doo as $key => $value) {
>   print "Key:$key Value:$value";  
>   break;
> }

How about

   reset($doo);
   $first_key = key($doo);

?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] array question

2003-03-10 Thread Ernest E Vogelsinger
At 16:35 10.03.2003, Jason Wong said:
[snip]
>Not very elegant -- there must be a better way?
>
>foreach ($doo as $key => $value) {
>  print "Key:$key Value:$value";  
>  break;
>}
[snip] 

Possibly using array_keys()?

$keys = array_keys($doo);
echo "First key is \"{$keys[0]}\"";

array_keys() comes in handy if you want to have random access to an
associtive array without knowing the keys.


-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] array question

2003-03-10 Thread Jason Wong
On Monday 10 March 2003 21:13, Diana Castillo wrote:
> If I sort an array, and now the keys are not in numerical order, how can I
> get the key of the first element?
> If I do array_shift I get the first element but I want that key.

Not very elegant -- there must be a better way?

foreach ($doo as $key => $value) {
  print "Key:$key Value:$value";  
  break;
}

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Questionable day.

Ask somebody something.
*/


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



RE: [PHP] array question

2003-02-24 Thread Johnson, Kirk
http://www.php.net/manual/en/language.variables.variable.php

Kirk

> -Original Message-
> From: Bob Irwin [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 24, 2003 3:28 PM
> To: php-general
> Subject: Re: [PHP] array question
> 
> 
> Hi Guys,
> 
> This might be a bit of  a newbie question, but I'm not sure 
> how to search
> for this particular information as its hard to put in search terms.
> 
> Say I have a mysql/file with information about variables.  
> Eg, I have a
> string from a mysql database of 'test'
> 
> Am I able to then, in PHP, assign whatever that string is to 
> a variable
> name?  Eg, the string 'test' is used to create the variable 
> '$test'...  What
> is in that variable, doesn't matter, just the fact that the 
> script knows the
> name of the variable (which can change depending on what the strings
> are)
> 
> I'm sure its an easy piece of code, like a string function, 
> but I'm buggered
> if I can find it!
> 
> 
> Best Regards
> Bob Irwin
> Server Admin & Web Programmer
> Planet Netcom
> 
> 
> Scanned by PeNiCillin http://safe-t-net.pnc.com.au/
> 
> -- 
> 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] array question

2003-02-24 Thread Bob Irwin
Hi Guys,

This might be a bit of  a newbie question, but I'm not sure how to search
for this particular information as its hard to put in search terms.

Say I have a mysql/file with information about variables.  Eg, I have a
string from a mysql database of 'test'

Am I able to then, in PHP, assign whatever that string is to a variable
name?  Eg, the string 'test' is used to create the variable '$test'...  What
is in that variable, doesn't matter, just the fact that the script knows the
name of the variable (which can change depending on what the strings
are)

I'm sure its an easy piece of code, like a string function, but I'm buggered
if I can find it!


Best Regards
Bob Irwin
Server Admin & Web Programmer
Planet Netcom


Scanned by PeNiCillin http://safe-t-net.pnc.com.au/

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



Re: [PHP] array question

2003-02-24 Thread Chris Edwards
try something like this:

$groups= file("group");
$number_in_group = count($groups);

for( $i = 0; $i < $number_in_group; $i++)
  {
  $temp = explode(":",$groups[$i]);
  $group[$i]['pass'] = $temp[1];
  $group[$i]['id'] = $temp[2];
  $group[$i]['list'] = $temp[3];
  }


for( $i = 0; $i < count( $group ); $i++)
  {
  echo "site" . $i . ":" . $group[$i]['pass'] . ":" . $group[$i]['id'] .
":";
  $temp = explode( ",", $group[$i]['list'] )
  foreach ($temp as $k => $v)
echo $v;
  }

--
Chris Edwards
Web Application Developer
Outer Banks Internet, Inc.
252-441-6698
[EMAIL PROTECTED]
http://www.OuterBanksInternet.com

- Original Message -
From: "Richard Kurth" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 3:23 PM
Subject: [PHP] array question


> This is the code I am using to get the data out of the text file
> below. Now I need to turn the $group[3] into an array of its own so
> that I can make changes to it. How do I turn this into an array that
> I can reference with $group[0]. What I need to be able to do is
> search for the label in $group[0] and then make changes to the stuff
> in $group[3] like delete add or change.
>
>  $groups= file("group");
> $number_in_group = count($groups);
> ?>
> 
>  for ($i=0; $i<$number_in_group; $i++){
> $group=explode(":",$groups[$i]);
> ?>
> 
> 
> 
> 
> 
> 
>
>
> The DATA
>
> site1:x:503:tester1
> site2:x:504:tester2,tester2a
> site3:x:505:tester3,tester3a,tester3b
> site4:x:506:tester4
> site5:x:507:tester5,tester5a,tester5b
> site6:x:508:tester6
> site7:x:509:tester7,tester7a,tester7b
>
>
>
> --
> Best regards,
>  Richard  mailto:[EMAIL PROTECTED]
>
>
> --
> 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] array question

2002-10-30 Thread Philip Olson
A very important question indeed :)




 print $_POST['interests'][0];
 print $_POST['interests'][1];




 print $_POST['interests']['foo'];
 print $_POST['interests']['bar'];

Read the manual section on arrays for more
information on using them.

  http://www.php.net/manual/en/language.types.array.php

Regards,
Philip

On Wed, 30 Oct 2002, Rick Emery wrote:

> What does you HTML look like?
> - Original Message - 
> From: "John Meyer" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 30, 2002 10:36 AM
> Subject: RE: [PHP] array question
> 
> 
> Either way, I'm not getting the interests.
> 
> -Original Message-
> From: Rick Emery [mailto:remery@;emeryloftus.com]
> Sent: Wednesday, October 30, 2002 9:34 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] array question
> 
> 
> What happened when you tried both methods?
> 
> - Original Message - 
> From: "John Meyer" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 30, 2002 10:29 AM
> Subject: [PHP] array question
> 
> 
> When retrieving an array from $_POST, which is the right way:
> 
> $arrInterests = $_POST["interests[]"];
> 
> or 
> $arrInterests = $_POST["interests"];
> 
> -- 
> 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
> 
> -- 
> 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
> 


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




Re: [PHP] array question

2002-10-30 Thread @ Edwin
Hello,

"John Meyer" <[EMAIL PROTECTED]> wrote:
> Either way, I'm not getting the interests.
> 
...[snip]... 
> 
> When retrieving an array from $_POST, which is the right way:
> 
> $arrInterests = $_POST["interests[]"];
> 
> or 
> $arrInterests = $_POST["interests"];
> 

Try this instead:

  $arrInterests = $_POST['interests'];

- E

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




Re: [PHP] array question

2002-10-30 Thread Rick Emery
What does you HTML look like?
- Original Message - 
From: "John Meyer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 10:36 AM
Subject: RE: [PHP] array question


Either way, I'm not getting the interests.

-Original Message-
From: Rick Emery [mailto:remery@;emeryloftus.com]
Sent: Wednesday, October 30, 2002 9:34 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] array question


What happened when you tried both methods?

- Original Message - 
From: "John Meyer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 10:29 AM
Subject: [PHP] array question


When retrieving an array from $_POST, which is the right way:

$arrInterests = $_POST["interests[]"];

or 
$arrInterests = $_POST["interests"];

-- 
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

-- 
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] array question

2002-10-30 Thread John Meyer
Either way, I'm not getting the interests.

-Original Message-
From: Rick Emery [mailto:remery@;emeryloftus.com]
Sent: Wednesday, October 30, 2002 9:34 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] array question


What happened when you tried both methods?

- Original Message - 
From: "John Meyer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 10:29 AM
Subject: [PHP] array question


When retrieving an array from $_POST, which is the right way:

$arrInterests = $_POST["interests[]"];

or 
$arrInterests = $_POST["interests"];

-- 
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

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




Re: [PHP] array question

2002-10-30 Thread Rick Emery
What happened when you tried both methods?

- Original Message - 
From: "John Meyer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 10:29 AM
Subject: [PHP] array question


When retrieving an array from $_POST, which is the right way:

$arrInterests = $_POST["interests[]"];

or 
$arrInterests = $_POST["interests"];

-- 
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] Array Question

2002-10-30 Thread Ford, Mike [LSS]
> -Original Message-
> From: PHP List [mailto:php_list@;ibcnetwork.net]
> Sent: 29 October 2002 17:20
> To: php
> Subject: Re: [PHP] Array Question
> 
> 
> No, array_keys does not do what I want, in order to user 
> array_keys, it
> assumes I know the value of the key, but I don't,

Er -- no.  Go read its definition again -- you *may* pass it a value for which you 
want the corresponding keys, but by omitting the value argument you may also ask for 
*all* of the keys of your array.

>  I want to 
> get the value of
> the key but all I know is the index.

First of all, I presume this means that, for example, if $index==4, you want to know 
what the key of the 4th array element is?

In that case, the following, whilst not ideal, may be your best solution:

   $keys = array_keys($array);
   $required_key = $keys[$index];

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




Re: [PHP] Array Question

2002-10-29 Thread PHP List
No, array_keys does not do what I want, in order to user array_keys, it
assumes I know the value of the key, but I don't, I want to get the value of
the key but all I know is the index.


> Perhaps you want to look at array_keys().
>
> On Monday, October 28, 2002, at 05:48 PM, PHP List wrote:
>
> > How can I get the name of the index?
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
>
>
> --
> 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] Array Question

2002-10-29 Thread Brent Baisley
Perhaps you want to look at array_keys().

On Monday, October 28, 2002, at 05:48 PM, PHP List wrote:


How can I get the name of the index?

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


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




RE: [PHP] Array Question

2002-10-29 Thread Ford, Mike [LSS]
> -Original Message-
> From: PHP List [mailto:php_list@;ibcnetwork.net]
> Sent: 28 October 2002 22:48
> To: php
> Subject: [PHP] Array Question
> 
> 
> Hi,
> Lets say I have a simple array like this:
> $myarray = array("a"=>"b","d"=>"c");
> 
> echo $myarray[0] will return 'b';
> 
> How can I get the name of the index? so:

I'd suggest a look at array_keys()
(http://www.php.net/manual/en/function.array-keys.php).  Seems to be the
nearest to what you want.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


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




Re: [PHP] Array Question

2002-10-28 Thread PHP List
This doesn't seem to work for anything past the first key:
echo array_search(0,$myarray);
will print 'a';

None of these give me anything:
echo array_search(1,$myarray);
echo array_search("1",$myarray);
echo array_search(1,$myarray,true);
echo array_search("1",$myarray,true);
so how do I get 'd'?



> I think you are looking for array_search()
>
> On Mon, 28 Oct 2002, PHP List wrote:
>
> > Hi,
> > Lets say I have a simple array like this:
> > $myarray = array("a"=>"b","d"=>"c");
> >
> > echo $myarray[0] will return 'b';
> >
> > How can I get the name of the index? so:
> >
> > echo $myarray[something] would return 'a';
> >
> > I know I can do a list($key,$value) but I don't need to loop through the
array, I just need to be able to retrieve the key name from any point in the
array.
> >
> >
> > Thanks for any help.
>
>
> --
> 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] Array Question

2002-10-28 Thread Rasmus Lerdorf
I think you are looking for array_search()

On Mon, 28 Oct 2002, PHP List wrote:

> Hi,
> Lets say I have a simple array like this:
> $myarray = array("a"=>"b","d"=>"c");
>
> echo $myarray[0] will return 'b';
>
> How can I get the name of the index? so:
>
> echo $myarray[something] would return 'a';
>
> I know I can do a list($key,$value) but I don't need to loop through the array, I 
>just need to be able to retrieve the key name from any point in the array.
>
>
> Thanks for any help.


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




Re: [PHP] Array question

2002-08-14 Thread Bas Jobsen

> How can I echo the name of the of the second array (subArray)?  The name
for value
array('1','2'.'3'),
'c'=>array('6','5'.'4'),
'd'=>array('8','9'.'10'),
);


$r=next($test);
echo $r[0].' or :'."\n";
foreach (next($test) as $value) echo $value;
?>

or do you need the keys?
something like:
echo implode(",",array_keys(next($test))); 

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




Re: [PHP] Array question - Finding the name

2002-06-07 Thread Philip Olson


> I want to find the name of the n-th value in an array.  Not the value of
> the n-th, but whatever name was given to it.  Array_slice seems to just
> pull part of an array and put it in another.  and key() isn't exactly
> what i want either..

Maybe this will help:

> $my_array = array('bob' => $x,  'jim' => $y, 'mike' => $z);

$keys = array_keys($my_array);

print $keys[0]; // bob
print $keys[1]; // jim

Regards,
Philip Olson


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




Re: [PHP] Array question - Finding the name

2002-06-07 Thread Jason Wong

On Friday 07 June 2002 23:59, Phil Schwarzmann wrote:
> Thanks for your reply!
>
> I tried using array_slice but I don't think that's exactly that I want
> to do.
>
> I want to find the name of the n-th value in an array.  Not the value of
> the n-th, but whatever name was given to it.  Array_slice seems to just
> pull part of an array and put it in another.  and key() isn't exactly
> what i want either..

list($key, $val) = each(array_slice($my_array, 1, 1))

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Absence is to love what wind is to fire.  It extinguishes the small,
it enkindles the great.
*/


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




Re: [PHP] Array question - Finding the name

2002-06-07 Thread Phil Schwarzmann

Thanks for your reply!

I tried using array_slice but I don't think that's exactly that I want
to do.

I want to find the name of the n-th value in an array.  Not the value of
the n-th, but whatever name was given to it.  Array_slice seems to just
pull part of an array and put it in another.  and key() isn't exactly
what i want either..


>>> [EMAIL PROTECTED] 06/07/02 10:53AM >>>
On Friday 07 June 2002 22:16, Phil Schwarzmann wrote:
> Let's say I have an array...
>
> $my_array[] = array('bob' => $x,  'jim' => $y, 'mike' => $z);

you probably meant to define it as:

$my_array = array('bob' => $x,  'jim' => $y, 'mike' => $z);

use print_r($my_array) to see the difference between your definition and
mine.

> Now I want to find the name of the second element in the array (I want
> my result to be 'jim')

> How do I do this?  I think I might have to use the key() function but
I
> can't quite get it to wkr.

Depends on whether you want to find the name of the 'n-th' element, or
the 
name of the element whose value is '$y'.

If the former you can use array_slice(), the latter key().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
ATM cell has no roaming feature turned on, notebooks can't connect
*/


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



Re: [PHP] Array question - Finding the name

2002-06-07 Thread Jason Wong

On Friday 07 June 2002 22:16, Phil Schwarzmann wrote:
> Let's say I have an array...
>
> $my_array[] = array('bob' => $x,  'jim' => $y, 'mike' => $z);

you probably meant to define it as:

$my_array = array('bob' => $x,  'jim' => $y, 'mike' => $z);

use print_r($my_array) to see the difference between your definition and mine.

> Now I want to find the name of the second element in the array (I want
> my result to be 'jim')

> How do I do this?  I think I might have to use the key() function but I
> can't quite get it to wkr.

Depends on whether you want to find the name of the 'n-th' element, or the 
name of the element whose value is '$y'.

If the former you can use array_slice(), the latter key().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
ATM cell has no roaming feature turned on, notebooks can't connect
*/


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




Re: [PHP] array question

2002-05-30 Thread Analysis & Solutions

On Thu, May 30, 2002 at 07:24:49PM -0400, Michelle wrote:

> Phone Number:
> 
> 
> which finally leads to my question how do I do the $_POST[var] when
> it's an array(checkbox or radio button)?
> 
> ex: red

   echo 'red';

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




RE: [PHP] array question

2002-05-30 Thread Martin Towell

$_POST["product"][0]
$_POST["product"][1]
etc.


-Original Message-
From: Michelle [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 31, 2002 9:25 AM
To: [EMAIL PROTECTED]
Subject: [PHP] array question


I'm a newbie at php and I'm sure you will be able to tell by my question.
I'm just doing a simple form but my head is hurting from trying to figure
out the correct syntax. 

I'm posting the form to $PHP_SELF

an example from my $form_block =

*Your Name:

 
*Your E-Mail Address:


Phone Number:


which finally leads to my question how do I do the $_POST[var] when it's an
array(checkbox or radio button)?

ex: red

Am I making sense? If not please let me know :-) and I will try to remedy
it.

Michelle

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




Re: [PHP] Array question - Please help

2002-05-23 Thread 1LT John W. Holmes

Write your results to a file and create a mail from the file once a day and
send it to yourself with cron, or use a database to hold the results if one
is available.

Instead of making a mail message with your loop, write information back to
the file. Format your file like this:

url, pass, fail, last_fail_time



The create another PHP script that simply loads up the .txt file and formats
an email with it to give you the results, and call it with cron/at.

I wrote that kind of quickly, so adapt to your needs and it may have
errors...but hopefully you get the idea. You can take out the isset() parts
if you want to go through and format your file in the correct format (with
all four columns). if you leave them in there, it'll basically take the file
you have now and reformat it to the new one the first time it's ran. Also
it'll make it so you can just add in a url, w/o having to put zero, zero,
and None for the other columns. adapt to your needs.

---John Holmes...

- Original Message -
From: "Dan McCullough" <[EMAIL PROTECTED]>
To: "PHP General List" <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 1:03 PM
Subject: [PHP] Array question - Please help


> Here is the problem.  I have over 60 subdomains to check on a regular
basis.  I wrote a php script
> that gets a list from a text file and then checks whether it can open that
domain/subdomain.  That
> works great.  My problem is that everything is lumped together, so I have
to scan a list of 60
> names for the one that fails, I also get 1 email for each time the check
fails.
>
> How can I get a list broken up by failed and passed, and only get one
email with a list of the
> subdomains that failed.
>
> Here is the script as it stands now.
>
> 
> $url_file = "url.txt";
> $url_list = file($url_file);
>
>   for($x = 0; $x < count($url_list); $x++)
>   {
>   $url_list[$x] = eregi_replace("[\n\r]","",$url_list[$x]);
>   $fp = fsockopen ($url_list[$x], 80, $errno, $errstr, 30);
> if (!$fp) {
> echo "$url_list[$x] has an error.  $errstr ($errno)\n";
> //$subject = "A URL test has failed";
> //$message = "$url_list[$x] has an error.  $errstr ($errno)\r\n";
>
> /*mail("[EMAIL PROTECTED]", $subject, $message, "From:
[EMAIL PROTECTED]\r\n"
> ."Reply-To: [EMAIL PROTECTED]\r\n"
> ."X-Mailer: PHP/" . phpversion());*/
>
> } else {
> echo "$url_list[$x] is up.\n";
> }
>   }
> ?>
>
> =
> 
> "Theres no such thing as a problem unless the servers are on fire!"
>
>
> __
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
>
> --
> 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] Array question - Please help

2002-05-23 Thread Jason Wong

On Friday 24 May 2002 01:03, Dan McCullough wrote:
> Here is the problem.  I have over 60 subdomains to check on a regular
> basis.  I wrote a php script that gets a list from a text file and then
> checks whether it can open that domain/subdomain.  That works great.  My
> problem is that everything is lumped together, so I have to scan a list of
> 60 names for the one that fails, I also get 1 email for each time the check
> fails.
>
> How can I get a list broken up by failed and passed, and only get one email
> with a list of the subdomains that failed.

When you loop through add the status for the domain onto a results array. When 
the loop is finished, then send the mail with the contents of the results 
array.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
To be is to program.
*/


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




Re: [PHP] array question

2002-05-17 Thread Jason Wong

On Friday 17 May 2002 18:42, Josh Edwards wrote:
> I have an array which I use a loop to add numbers to different elements in
> the array. I can extract the highest no
> which in this case is 48. ie ([22 ] => 48 [23 ] => 2 [12 ] => 22 [14 ] =>
> 5 )
>
> Using this highest no (48 in this instance), how do I get the position or
> [element No] that matches the highest no.

RTFM -> array_search()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
interrupt configuration error
*/


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




Re: [PHP] Array question

2002-04-23 Thread Michal Dvoracek

Hello,

i think that unset($a['color']); is the best way :)

Regards
Michal Dvoracek  [EMAIL PROTECTED]


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




Re: [PHP] Array Question

2002-04-19 Thread Erik Price


On Thursday, April 18, 2002, at 05:38  PM, Jason Lam wrote:

> But,
>
> $arr1[0] = 1;
> $arr1[1] = 10;
> $arr2[0] = $arr1;
> $arr3 = each($arr2);
> print $arr3[1];
>
> Result is not 10. So, function "each" is not taking the whole $arr2[0]
> out..
>
> My question is what function should I use to iterate array elements 
> (with
> arrays in it)?

$arr3 = (list($arr3) = each($arr2));

I think.  Untested.






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Array Question

2002-04-18 Thread Steve Cayford


On Thursday, April 18, 2002, at 04:38  PM, Jason Lam wrote:

> $arr2 is a 2d array.
>
> $arr1[0] = 1;
> $arr1[1] = 10;
> $arr2[0] = $arr1;
> print $arr2[0][1];
>
> Result will be 10
>
> But,
>
> $arr1[0] = 1;
> $arr1[1] = 10;
> $arr2[0] = $arr1;
> $arr3 = each($arr2);
> print $arr3[1];

What are you expecting? Check out the documentation for each() at 
http://www.php.net/manual/en/function.each.php

At this point $arr3 should look like this (I think, but try 
print_r($arr3) to be sure):

{
0 => 0,
1 => array (
0 => array (
0 => 1,
1 => 10
)
),
key => 0,
value => array (
0 => array (
0 => 1,
1 => 10
)
)
}

>
> Result is not 10. So, function "each" is not taking the whole $arr2[0]
> out..
>
> My question is what function should I use to iterate array elements 
> (with
> arrays in it)?
>

How about foreach()?

-Steve

> Jay
>
>
> --
> 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] Array Question

2002-03-26 Thread Jim Lucas [php]

I can make this just a little easier..  try this

$query = "SELECT * FROM mytable WHERE t_state_id_state in ('" .join("', '",
$state). "')";

if $state happens to be the name of the array that is passed from the
multi-select

Jim Lucas
www.bend.com
- Original Message -
From: "Rick Emery" <[EMAIL PROTECTED]>
To: "'John Fishworld'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, March 26, 2002 10:07 AM
Subject: RE: [PHP] Array Question


> $n =sizeof($state);
>
> $srch = "";
> while( $x=0; $x<$n; $x++)
> {
>... do something with array element $state[$x] ...
>$srch .= $state[$x].", ";
> }
> $srch = rtrim($srch,", ");
> $query = "SELECT * FROM mytable WHERE t_state_id_state in ($srch)";
>
> -Original Message-
> From: John Fishworld [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 26, 2002 11:51 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Array Question
>
>
> I have some multiple select boxes in a form
> ie
>  
>   all Regions 
>   Region19 
>   Region14
>   Region15
>
> these then get passed and I want to use them in mysql query
>
> blah blah
> WHERE
>   (t_state_id_state = $state[0])
>
> Whats the best way of finding out how many items are in my array ?
> And how can I step through the ones the exist ?
> And can I only use LIKE % when my value is all ?
>
> thanks
>
>
>
> --
> 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
>
>


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




Re: [PHP] Array question

2001-09-18 Thread Gerard Samuel

Try this.

  $sql = "select bp_section_id,bp_section_name from bp_sections order by
  bp_section_name";
  $sql_result = mssql_query($sql);
  while ($row = mssql_fetch_array($sql_result)){
  $bp_section_id = $row["bp_section_id"];
  $bp_section_name = $row["bp_section_name"];
  $ln = "$bp_section_name";
 

$new_data[] = $variable_or_array[element];
  };




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Array Question

2001-09-13 Thread Philip Olson

see array_slice()

  http://php.net/manual/en/function.array-slice.php

regards,
philip olson


On Thu, 13 Sep 2001, dhardison wrote:

> Hi,
> I've got an array of items that I've sorted in descending order. I'd
> like to select the first ten items only  from the array to place in a graph
> that's generated later in the script.  Here's a sample array I'm trying to
> work with.
> 
>  Array
> (
> [209.181.49.x] => 2
> [64.225.143.x] => 2
> [63.174.69.x] => 1
> [207.217.120.x] => 1
> [164.109.19.x] => 1
> [205.197.83.x] => 1
> [24.155.23.x] => 1
> [24.237.4.x] => 1
> [161.58.135.x] => 1
> [216.33.156.x] => 1
> [64.14.48.x] => 1
> [64.38.239.x] => 1
> [203.155.4.x] => 1
> [204.176.182.x] => 1
> [64.12.136.x] => 1
> [208.7.216.x] => 1
> [64.70.22.x] => 1
> [63.225.237.x] => 1
> [205.197.83.x] => 1
> [209.67.135.x] => 1
> [64.14.48.x] => 1
> [205.197.83.x] => 1
> [206.67.234.x] => 1
> )
> 
> How could I grab the first ten pairs and store them for use later in the
> script?
> 
> Thanks,
> dhardison
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] array question

2001-07-19 Thread Taylor, Stewart

Try using mysql_fetch_array instead of mysql_fetch_object.

You then then use a simple loop to assign your variables
e.g.

foreach($row as $k=>$v)
{
   $GLOBALS[$k] = $v; // or $GLOBALS[$k][$i++] = $v if multiple records
being read
}

This will result in a set of global variables matching your database fields
names.

-Stewart

-Original Message-
From: James W Greene [mailto:[EMAIL PROTECTED]]
Sent: 19 July 2001 18:37
To: php-general
Subject: [PHP] array question


Hi All,
I am trying to pull info out of a table and assign a var name to each
field...  I seem to be having trouble.  I have tried to do $var = $row[0]
but that does not seem to do it.  I have included what is working below.  I
would like to have each element of the array stored in a seperate variable
for use on a  web page. Thanks
JG

UserName) ;
// **Would like to do something like**//
// $user = $row[0]; //

}
mysql_free_result($result);
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Array question

2001-05-16 Thread David Robley

On Thu, 17 May 2001 08:26, Matthias Roggendorf wrote:
> Hi,
> I wrote some code and I do not understand the result I get:
>
> while ($data = fgetcsv ($fp, 1000, ",")) $line[$j++] = $data;
>
> When I ouput $line[0][0] I get Array[0] instead of the real value.
>
> Why is that?
>
> Thanks for your help,
>
> Matthias

>From the docs:

"Similar to fgets() except that fgetcsv() parses the line it reads for 
fields in CSV format and returns an array containing the fields read. The 
field delimiter is a comma, unless you specify another delimiter with the 
optional third parameter."

So it seems that $data will be an array of the current line being 
returned from the file? Have a look at the docs 
(/manual/en/function.fgetcsv.php) for an example of how to read and 
output the contents of a csv file.

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   hAS ANYONE SEEN MY cAPSLOCK KEY?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] array question

2001-02-23 Thread Christian Reiniger

On Friday 23 February 2001 17:02, Jeff wrote:
> Is there better performance/speed instantiating an array with a
> specified size and then adding elements versus adding elements to an
> array with no size?

Uh, you can't specify the size when instatiating an array ...

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

...1000100011010101101010110100111010113...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Array question

2001-02-15 Thread Chris

Ok,
But can't the array still be refered to with a number?
So in myarray["something"] is the 50th element in the array, wouldn't:
 
myarray[49] = myarray["something"]

?



> On Thursday 15 February 2001 01:40, Chris wrote:
> 
> > How do I get the index,number of an array if reffering to an array via
> > string? Ex:
> > I have 100 arrays, and I want to know what #  myarray["something"] is.
> 
> That element doesn't have an index number such arrays are implemented as 
> hashes or trees, which don't store data at "fixed positions" (that's a 
> very bad explanation, but, well...)
> The "index" is the "key" in this case - in your example it's "something".
> 
> -- 
> Christian Reiniger
> LGDC Webmaster (http://sunsite.dk/lgdc/)
> 
> I saw God - and she was black.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Array question

2001-02-15 Thread Christian Reiniger

On Thursday 15 February 2001 01:40, Chris wrote:

> How do I get the index,number of an array if reffering to an array via
> string? Ex:
> I have 100 arrays, and I want to know what #  myarray["something"] is.

That element doesn't have an index number such arrays are implemented as 
hashes or trees, which don't store data at "fixed positions" (that's a 
very bad explanation, but, well...)
The "index" is the "key" in this case - in your example it's "something".

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

I saw God - and she was black.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]