Php Toycode - Convert a Hash to an Array
Simple example to convert a hash to an array.
Php in Action
Php Code
Just cut-n-paste to reuse.
<?php
//hash storing an array
$aarr["1993-03-02"] = '';
$aarr["1992-11-30"] = '';
$aarr["1996-12-01"] = '';
$aarr["1992-01-22"] = '';
$aarr["1992-12-14"] = '';
$aarr["1993-03-11"] = '';
$iarr=array();
//loop through assoc array
foreach( $aarr as $key => $value)
{
echo "$key";
echo " => $value";
echo "<br \>";
array_push($iarr,$key);
}
$sz = sizeof($iarr);
echo "size of array is " . $sz . "<br />";
rsort($iarr);
for ($i=0;$i<$sz;$i++)
{
echo $iarr[$i] . "<br />";
}
?>
If you find this site useful and are a book buyer/reader...
Abe Books is one of my affiliates. I only use affiliates that I also purchase products from. I love Abe books. I have purchased many books from them originally cost $40 to $60 for as little as $5 to $10 dollars including shipping costs.
By accessing Abe books and clicking on one of my links I receive a small commission on your purchase that helps pay for this site. You pay no more for your books than if you accessed their site directly. Thanks for your support.
Click on icon to find books on Php at Abe Books... |
|
|
|
The Following are a list of Php books I own
- PHP Hacks: Tips & Tools for Creating Dynamic Web Sites by Jack D Herrington
- PHP Cookbook by David Sklar; Adam Trachtenberg
- Php: Your Visual Blueprint for Creating Open Source, Server-Side Content
- Php In Action by Dagfinn Reiersol
- Php 5 Objects, Patterns, and Practice
A few notes. Already having a rich programming background when I set out to learn Php I
found the Visual Blueprint book invaluable. I was literally able to get up to speed on Php
over a weekend. Of course it took many months of working in that language to really feel
proficient.
Having already had a decent background in Object Oriented Programming in Java I found the
two books "Php in Action" and "Php 5 Objects..." very well written and informative. I think
they are written by folks with "real world" experience on the subject.
|
 |