Here is your cup of coffee.  Brewed from the finest Colombian lighter fluid.

Xander ,'Chosen'


Buffistas Building a Better Board  

Do you have problems, concerns or recommendations about the technical side of the Phoenix? Air them here. Compliments also welcome.

To-do list


Typo Boy - Nov 19, 2002 7:09:08 am PST #1615 of 10000
Calli: My people have a saying. A man who trusts can never be betrayed, only mistaken.Avon: Life expectancy among your people must be extremely short.

Hey, anyone, what's the correct way to get the last item of an array in PHP? I can't seem to see it in the online manual -- should I just use
$array_name[count($array_name)] or what? It looks clunky.

$value = end ($array);

There are some nice array navigation commands in PHP. end($array) resests the internal pointer PHP maintains for each array to the last element of $array and returns the value.

reset($array) resets internal pointer to first element of array, and returns the value of that first element.

current($array) returns the value element of the array to which the pointer is set.

next($array) advances the pointer and returns the value of the resulting element.

each($array) returns the current element, then advances the pointer.

so next() and each() are differentways of navigating an array forward.

prev($array) decrements the pointer by 1, and returns to the new current element.

Also, if you have not used it, look up array_walk(). Basically a for next loop specifically for arrays.

Also, I assume you know that in PHP an array does not have to be accesed by number. You set up an associative array as follows:

$myrRecord=array("LastName"="Horner", "FirstName"="John", "Company"="ThatAussieNetwork");

Then use the extract function as follows:

extract($myrecord);

You will now have a scaler variable LastName with a value of Horner and so forth.

So: echo $LastName $FirstName $Company ;

will return

Horner John ThatAussieNetwork

You don't have to use the extract() function of course. You can access the array directly by index values rather than number.

echo $MyRecord["LastName"] $MyRecord["FirstName"] $MyRecord["Company"] ;

will also display;

Horner John ThatAussieNetwork


Jon B. - Nov 19, 2002 7:55:38 am PST #1616 of 10000
A turkey in every toilet -- only in America!

Actually, in both cases, it will display

Horner John ThatAussieNetwork

t /nitpick


Katie M - Nov 19, 2002 9:40:30 am PST #1617 of 10000
I was charmed (albeit somewhat perplexed) by the fannish sensibility of many of the music choices -- it's like the director was trying to vid Canada. --loligo on the Olympic Opening Ceremonies

Okay, something comprehensible flew by and now I have a question...

Quotes? In links? Am I doing something wrong by just using a href and not putting any quotes in there, whether single or double?


Jessica - Nov 19, 2002 9:42:03 am PST #1618 of 10000
And then Ortus came and said "It's Ortin' time" and they all Orted off into the sunset

test

[edit: Well, I'll be. That's

<a href=http://www.link.com>test</a>

which I didn't think was supposed to work. Anyone know why it does anyway?]


§ ita § - Nov 19, 2002 9:45:00 am PST #1619 of 10000
Well not canonically, no, but this is transformative fiction.

Not using quotes is, IIRC, deprecated. Quotes are recommended (and hopefully soon mandated for the forgetful among us == me) for all attributes. They are currently mandatory for any attribute with a space or other special thingy in them.

t font face="Arial Rounded MT Bold" for instance, although one should say t font face="Arial" and not t font face=Arial .


Jessica - Nov 19, 2002 9:47:35 am PST #1620 of 10000
And then Ortus came and said "It's Ortin' time" and they all Orted off into the sunset

Ah -- I thought they were mandatory for all attributes already.


Typo Boy - Nov 19, 2002 9:58:35 am PST #1621 of 10000
Calli: My people have a saying. A man who trusts can never be betrayed, only mistaken.Avon: Life expectancy among your people must be extremely short.

Actually, in both cases, it will display

Horner John ThatAussieNetwork

</nitpick>

Thanks. Now corrected.


Katie M - Nov 19, 2002 10:19:07 am PST #1622 of 10000
I was charmed (albeit somewhat perplexed) by the fannish sensibility of many of the music choices -- it's like the director was trying to vid Canada. --loligo on the Olympic Opening Ceremonies

Ah. So I should being using quotes for everything after an =, then? So for font color as well?


Katie M - Nov 19, 2002 10:19:08 am PST #1623 of 10000
I was charmed (albeit somewhat perplexed) by the fannish sensibility of many of the music choices -- it's like the director was trying to vid Canada. --loligo on the Olympic Opening Ceremonies

§ ita § - Nov 19, 2002 11:08:31 am PST #1624 of 10000
Well not canonically, no, but this is transformative fiction.

Yup.