RE: Re: "My truth comes out" [1]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>-----Original Message-----
>From: Gary [mailto:php-general@xxxxxxxxxxxxxxx] 
>Sent: 21 October 2010 11:39
>To: php-general@xxxxxxxxxxxxx
>Subject:  Re: "My truth comes out" [1]
>
>Russell Dias wrote:
>
> preg_match("/false/i", $string) ? false : true;
>
>,----
>| $foo = (strcmp('true', $string) == 0);
>`----
>works as well :) I don't like those kinds of things for this purpose
>because it takes longer for people new to the code to read and
>understand it than, say
>,----
>| (boolean) $string;
>`----
>(which in my case does a pretty meaningless conversion)
>
>No, I was just wondering whether I had missed some construct in the
>language that might the conversion for me, and be obvious to
>PHP-heads. No problem that there doesn't seem to be.
>

What about something simple and readable like:

($string=="true") ? true : false;


J


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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux