OAH
OAH

Reputation: 335

Comma in in php arrays in function signatures

I am going through the documentation of couple of PHP functions and I keep seeing the pattern of having a comma in the beginning of the arrays when used as function arguments as shown below:

int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )

More specifically

[,array...] and [,int $offset]..

Upvotes: 2

Views: 61

Answers (1)

B. Desai
B. Desai

Reputation: 16436

It is not an array with , in begining. Its an optional parameters. In General parameters in [] i.e. square brackets indicates that, Those parameters are optional. You can pass arguments only if needed. Otherwise you can skip it.

Upvotes: 2

Related Questions