Zack
Zack

Reputation: 1575

Reading and understanding the PHP manual description

I am currently going through the PHP manual and I am having a problem reading the description. For example on this array_slice method description:

array array_slice ( array $array , int $offset [, int $length = NULL [, bool $preserve_keys = false ]] )

or maybe a simple one of substr:

string substr ( string $string , int $start [, int $length ] )

I do not understand the [, that comes after $offset and NULL. Where can I read on this or what does the [, mean and how do you read it?

Upvotes: 5

Views: 288

Answers (1)

Mikolaj
Mikolaj

Reputation: 708

The [ ] usually show optional parameters. So the [, is saying you could, but don't have to do array_slice($array, $offset, $length) the $length parameter is optional.

You could only do array_slice($array, $offset).

Upvotes: 2

Related Questions