|
Posted by Rik Wasmus on 10/02/07 17:51
On Mon, 01 Oct 2007 20:44:21 +0200, lawrence k <lkrubner@geocities.com> =
=
wrote:
> I've got a function that starts off like this:
>
> function alphabeticalListOfAlbumsByLetter($whichLetter=3D"a") {
>
> }
>
>
> I pass in the letters (a, b, c, d, etc) and the numbers (0, 1, 2, 3,
> 4, etc). It finds in the database records starting with that letter or=
> number. It works fine except when I try to pass in a zero. The PHP
> code acts as if I have not passed in a function argument, so
> $whichLetter becomes "a", which is the default value (as you can
> see).
>
> So how do I get PHP to see that I'm really passing in a zero, and not
> just some false value?
As you need a string, I'd say: cast it to one, and check it's length.
//if you always just need a single character:
if(strlen($whichLetter)=3D=3D1){
//do your thing
}
//or if it just needs to be 1 or more:
if(strlen($whichLetter)>=3D1){
//do your thing
}
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|