Skip to content

Instantly share code, notes, and snippets.

@mayeenulislam
Last active August 29, 2015 14:05
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 mayeenulislam/8860d366138925178e7d to your computer and use it in GitHub Desktop.
Save mayeenulislam/8860d366138925178e7d to your computer and use it in GitHub Desktop.
Foreach Loop from Associative Array
<?php
// A simple foreach() loop from an array
$age_array = array(
'0-18' => '0 - 18',
'19-25' => '19 - 25',
'26-30' => '26 - 30',
'31-50' => '31 - 50',
'51-65' => '51 - 65',
'66-80' => '66 - 80',
'81-100' => '81 - 100',
'100+' => '100+'
);
foreach ( $age_array as $age => $string ) {
echo '<input type="radio" name="client_age" id="client_age" value="'. $age .'" /> '. $string .'<br>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment