Skip to content

Instantly share code, notes, and snippets.

@matugm
Created September 28, 2012 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matugm/3801039 to your computer and use it in GitHub Desktop.
Save matugm/3801039 to your computer and use it in GitHub Desktop.
<pre>
<?php
// Creating an array
$chars = array();
array_push($chars,'a','b','c');
// Printing the contents
print_r($chars);
// Getting the lenght
$size = count($chars);
echo $size;
echo "<br>";
// Adding key/value pair
$chars['name'] = 'John';
print_r($chars);
// Iterating
foreach ($chars as $char) {
echo $char;
echo "<br>";
}
foreach ($chars as $key => $value ) {
echo "Key: " . $key . " Value: ". $value;
echo "<br>";
}
?>
</pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment