php-general Digest 9 Apr 2011 22:30:33 -0000 Issue 7265

2011-04-09 Thread php-general-digest-help

php-general Digest 9 Apr 2011 22:30:33 - Issue 7265

Topics (messages 312316 through 312321):

Re: pick a card, any card...
312316 by: Scotty Logan
312317 by: Simon J Welsh
312318 by: Curtis Maurand
312320 by: Curtis Maurand

Re: Security Question
312319 by: tedd

Re: the best 1 book for php
312321 by: domih

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On Apr 8, 2011, at 8:20 PM, Kirk Bailey wrote:
 in otherwords, the entire idea of picking one of N objects, whatever they 
 are- strings, numbers, gummybears, lined up in a listing, and return the one 
 item selected. This seems a common enough function there should be a simple 
 way to do it already in php. HOWEVER, I ain't findin' it that way, no 
 sir/maam/other.
 Maybe I am missing the obvious SIMPLE way to get the job done. So if we have 
 a listing of foo's, we can title this $listing, and we want 1 of them to be 
 returned, we should see something like:
 randmember($listing)

array_rand() - it's already built-in - 
http://php.net/manual/en/function.array-rand.php

  Scotty

 

---End Message---
---BeginMessage---
On 9/04/2011, at 3:39 PM, Scotty Logan wrote:

 On Apr 8, 2011, at 8:20 PM, Kirk Bailey wrote:
 in otherwords, the entire idea of picking one of N objects, whatever they 
 are- strings, numbers, gummybears, lined up in a listing, and return the one 
 item selected. This seems a common enough function there should be a simple 
 way to do it already in php. HOWEVER, I ain't findin' it that way, no 
 sir/maam/other.
 Maybe I am missing the obvious SIMPLE way to get the job done. So if we have 
 a listing of foo's, we can title this $listing, and we want 1 of them to be 
 returned, we should see something like:
 randmember($listing)
 
 array_rand() - it's already built-in - 
 http://php.net/manual/en/function.array-rand.php
 
  Scotty

Just note that array_rand() returns a random (or an array of random) key(s), 
not the values.
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e

---End Message---
---BeginMessage---



seems to me that you have an array with integers as the keys.

$desired_key = rand(0, count($array));

$desired_value =
$array[$desired_key];

Cheers,
Curtis


Simon J Welsh wrote:
 On 9/04/2011, at 3:39 PM, Scotty Logan
wrote:
 
 On Apr 8, 2011, at 8:20 PM, Kirk Bailey
wrote:
 in otherwords, the entire idea of picking one of
N objects, whatever
 they are- strings, numbers,
gummybears, lined up in a listing, and
 return the one
item selected. This seems a common enough function there

should be a simple way to do it already in php. HOWEVER, I ain't
 findin' it that way, no sir/maam/other.

Maybe I am missing the obvious SIMPLE way to get the job done. So if we
 have a listing of foo's, we can title this $listing, and we
want 1 of
 them to be returned, we should see something
like:
 randmember($listing)


array_rand() - it's already built-in -

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

  Scotty
 
 Just note that array_rand()
returns a random (or an array of random)
 key(s), not the
values.
 ---
 Simon Welsh
 Admin of
http://simon.geek.nz/
 
 Who said Microsoft never
created a bug-free program? The blue screen
 never, ever
crashes!
 

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
 
 
 --
 PHP General Mailing List
(http://www.php.net/)
 To unsubscribe, visit:
http://www.php.net/unsub.php
 

---End Message---
---BeginMessage---


Curtis Maurand wrote:
 
 
 
 seems to
me that you have an array with integers as the keys.
 

$desired_key = rand(0, count($array));

sorry, I hadn't had
coffee, yet.  The line above should be:

$desired_key = rand(0, count($array) - 1);

 
 $desired_value = $array[$desired_key];
 
 Cheers,
 Curtis
 
 Simon J
Welsh wrote:
 On 9/04/2011, at 3:39 PM, Scotty Logan
 wrote:

 On Apr 8, 2011, at 8:20 PM,
Kirk Bailey
 wrote:
 in otherwords, the
entire idea of picking one of
 N objects, whatever
 they are- strings, numbers,
 gummybears, lined
up in a listing, and
 return the one
 item
selected. This seems a common enough function there

 should be a simple way to do it already in
php. HOWEVER, I ain't
 findin' it that way, no
sir/maam/other.

 Maybe I am missing the
obvious SIMPLE way to get the job done. So if we

have a listing of foo's, we can title this $listing, and we
 want
1 of
 them to be returned, we should see something
 like:
 randmember($listing)


 array_rand() - it's already
built-in -


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

  Scotty

 Just note that
array_rand()
 returns a 

Re: [PHP] pick a card, any card...

2011-04-09 Thread Simon J Welsh
On 9/04/2011, at 3:39 PM, Scotty Logan wrote:

 On Apr 8, 2011, at 8:20 PM, Kirk Bailey wrote:
 in otherwords, the entire idea of picking one of N objects, whatever they 
 are- strings, numbers, gummybears, lined up in a listing, and return the one 
 item selected. This seems a common enough function there should be a simple 
 way to do it already in php. HOWEVER, I ain't findin' it that way, no 
 sir/maam/other.
 Maybe I am missing the obvious SIMPLE way to get the job done. So if we have 
 a listing of foo's, we can title this $listing, and we want 1 of them to be 
 returned, we should see something like:
 randmember($listing)
 
 array_rand() - it's already built-in - 
 http://php.net/manual/en/function.array-rand.php
 
  Scotty

Just note that array_rand() returns a random (or an array of random) key(s), 
not the values.
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


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



Re: [PHP] pick a card, any card...

2011-04-09 Thread Curtis Maurand



seems to me that you have an array with integers as the keys.

$desired_key = rand(0, count($array));

$desired_value =
$array[$desired_key];

Cheers,
Curtis


Simon J Welsh wrote:
 On 9/04/2011, at 3:39 PM, Scotty Logan
wrote:
 
 On Apr 8, 2011, at 8:20 PM, Kirk Bailey
wrote:
 in otherwords, the entire idea of picking one of
N objects, whatever
 they are- strings, numbers,
gummybears, lined up in a listing, and
 return the one
item selected. This seems a common enough function there

should be a simple way to do it already in php. HOWEVER, I ain't
 findin' it that way, no sir/maam/other.

Maybe I am missing the obvious SIMPLE way to get the job done. So if we
 have a listing of foo's, we can title this $listing, and we
want 1 of
 them to be returned, we should see something
like:
 randmember($listing)


array_rand() - it's already built-in -

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

  Scotty
 
 Just note that array_rand()
returns a random (or an array of random)
 key(s), not the
values.
 ---
 Simon Welsh
 Admin of
http://simon.geek.nz/
 
 Who said Microsoft never
created a bug-free program? The blue screen
 never, ever
crashes!
 

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
 
 
 --
 PHP General Mailing List
(http://www.php.net/)
 To unsubscribe, visit:
http://www.php.net/unsub.php
 



RE: [PHP] Security Question

2011-04-09 Thread tedd

At 2:53 PM -0500 4/8/11, Jay Blanchard wrote:

[snip]
whats the best way to learn about security in php?
[/snip]

Study, study, study!

Chris Shiflett is a recognized expert on PHP security -
http://shiflett.org/

He has a great book on PHP Security -
http://www.amazon.com/exec/obidos/ASIN/059600656X/ref=nosim/chrisshiflet
t-20


!++

Cheers,

tedd



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

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



Re: [PHP] pick a card, any card...

2011-04-09 Thread Curtis Maurand


Curtis Maurand wrote:
 
 
 
 seems to
me that you have an array with integers as the keys.
 

$desired_key = rand(0, count($array));

sorry, I hadn't had
coffee, yet.  The line above should be:

$desired_key = rand(0, count($array) - 1);

 
 $desired_value = $array[$desired_key];
 
 Cheers,
 Curtis
 
 Simon J
Welsh wrote:
 On 9/04/2011, at 3:39 PM, Scotty Logan
 wrote:

 On Apr 8, 2011, at 8:20 PM,
Kirk Bailey
 wrote:
 in otherwords, the
entire idea of picking one of
 N objects, whatever
 they are- strings, numbers,
 gummybears, lined
up in a listing, and
 return the one
 item
selected. This seems a common enough function there

 should be a simple way to do it already in
php. HOWEVER, I ain't
 findin' it that way, no
sir/maam/other.

 Maybe I am missing the
obvious SIMPLE way to get the job done. So if we

have a listing of foo's, we can title this $listing, and we
 want
1 of
 them to be returned, we should see something
 like:
 randmember($listing)


 array_rand() - it's already
built-in -


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

  Scotty

 Just note that
array_rand()
 returns a random (or an array of random)
 key(s), not the
 values.
 ---
 Simon Welsh
 Admin of

http://simon.geek.nz/

 Who said Microsoft
never
 created a bug-free program? The blue screen

never, ever
 crashes!



http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


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





[PHP] Re: the best 1 book for php

2011-04-09 Thread domih

Not one book.

1. For learning from scratch

One of the books recommended by the other esteemed posters.

2. Reference

http://www.php.net/manual/en/ and/or the corresponding CHM.

3. OOP with PHP

PHP Objects, Patterns and Practice, Third Edition

http://apress.com/book/view/9781430229254

4. More Tips and tricks

PHP Cookbook, Second Edition

http://oreilly.com/catalog/9781565926813

5. Security

Pro PHP Security
From Application Security Principles to the Implementation of XSS 
Defenses, 2nd Edition


http://www.apress.com/9781430233183

6. PEAR

http://pear.php.net/

7. PCEL

http://pecl.php.net/


With these you're set for many years of PHP enjoyment.

Dominique


On 4/6/2011 9:15 PM, Kirk Bailey wrote:

If I only had 1 book on php, what would it be?




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