|
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]
|