You are here: Re: array and value type « PHP Programming Language « IT news, forums, messages
Re: array and value type

Posted by Jon Slaughter on 05/14/07 03:55

"gosha bine" <stereofrog@gmail.com> wrote in message
news:4646fd34$0$2892$6e1ede2f@read.cnntp.org...
> Jon Slaughter wrote:
>> I want to create function that takes either an array or a simple type but
>> I want it not to distinguish between them,
>>
>>
>> function Decrypt(&$str)
>> {
>> foreach($str as &$val)
>> {
>> $val = rtrim($val,'enc');
>> }
>> return $str;
>> } //
>>
>> So here Decrypt can be called with an array or any type but the code
>> should be the same
>>
>
> I have the following function in my 'standard library'
>
> function ary($a = NULL) {
> return is_null($a) ? array() : (is_array($a) ? $a : func_get_args());
> }
>
> using this, your 'Decrypt' and other 'polymorphic' functions can be
> simplified to
>
> function polyfunc($arg) {
> foreach(ary($arg) as $val)
> .....
>
> }

Cool that will work just fine.

Thanks, Jon

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация