Back to lesson Try it Yourself
PHP Array Functions
PHP
Result

PHP runs on a web server

Browsers can't run PHP. To try this code: install XAMPP, save it as a file in htdocs (use Download above), then open it at http://localhost/yourfile.php.

Output
Array
(
    [0] => Kisumu
    [1] => Nakuru
    [2] => Eldoret
    [3] => Kisumu
)
Array
(
    [0] => Kisumu
    [1] => Nakuru
    [2] => Eldoret
)
Array
(
    [0] => 20
    [1] => 30
    [2] => 40
)
Array
(
    [0] => 3
    [1] => 2
    [2] => 1
)
Array
(
    [7] => Ivy
    [9] => Joe
)

Keyboard shortcuts

Ctrl + EnterRun the code
Ctrl + SSave in this browser
Ctrl + /Comment / uncomment line
Tab / Shift + TabIndent / outdent
Ctrl + Z / Ctrl + YUndo / redo
Ctrl + FFind (browser search)

Your code is saved automatically in this browser. Share copies a link that opens this exact code. Code runs in a safe sandbox – it can't see your account.

Are you sure?