Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
Last active August 29, 2015 14:25
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 kevinwhoffman/45b55c621dec319d367a to your computer and use it in GitHub Desktop.
Save kevinwhoffman/45b55c621dec319d367a to your computer and use it in GitHub Desktop.
Checking price based on zip code
$zip = '00001'; // $zip can be populated by form submission
$pricing = $array(
// zip => price associated with that zip
'00001' => 10,
'00002' => 15,
'00003' => 20
);
// check if zip exists within array, and return the matching price
if ( in_array( $zip, $pricing ) ) {
return $pricing[$zip]; // returns 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment