← CodePrimer
PHP
Beginner
Basics
Essential array functions
How do I count, push, pop, and sort arrays?
count, array_push, sort…
<?php
$nums = [3, 1, 2];
echo count($nums);
array_push($nums, 4);
array_pop($nums);
sort($nums); // reindexes
$assoc = ['b' => 2, 'a' => 1];
ksort($assoc); // sort by key
Notes
asort sorts associative arrays by value and keeps keys.
Keywords: count · array_push · array_pop · sort · ksort
Related
HTML
HTML headings h1–h6
How do I create page headings?
CSS
Three ways to apply CSS
What are inline, internal, and external CSS?
PHP
Embed PHP inside HTML
How do I mix PHP and HTML?
HTML
Paragraphs and line breaks
How do I break text into paragraphs?
CSS
CSS box model
Why is my element wider than expected?
PHP
PHP comments
How do I write comments in PHP?