You are here: Re: How to tell php a variable is an array? « PHP Programming Language « IT news, forums, messages
Re: How to tell php a variable is an array?

Posted by Chung Leong on 04/14/06 01:20

sueyic@gmail.com wrote:
> Hello,
>
> What is the syntax for telling php that a variable is an array, or an
> array of arrays?
>
> Let's say I have $arrTerms
>
> /*
> @param array of arrays $arrTerms
> */
> function test($arrTerms) {
> $anotherArray = array('1', '2');
>
> $intersect = array_intersect($anotherArray, $arrTerms[0]);
>
> }
>
> This doesn't work and php tells me I'm trying to access $arrTerms[0] as
> a array though it is not.
>
> But actually, since $arrTerms is supposed to be an array of arrays --
> $arrTerms[0] is an array ... how can I tell php this?

To tell if a variable holds an array--use is_array(). To force a
variable into being an array, do (array) $var or settype($var,
'array').

 

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

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