Skip to content

Instantly share code, notes, and snippets.

@jwhb
Last active December 28, 2015 08:29
Show Gist options
  • Save jwhb/7472193 to your computer and use it in GitHub Desktop.
Save jwhb/7472193 to your computer and use it in GitHub Desktop.
PHP switch structure that fills an array with default values up to a specific index
<?php
$params = array('users', 'JWhy', 'repositories');
$n_params = sizeof($params);
switch($n_params){
case 0:
die('Not enough information supplied');
break;
case 1:
$params[1] = '';
$n_params = 2;
case 2:
$params[2] = '';
$n_params = 3;
case 3:
$params[3] = '';
$n_params = 4;
case 4:
//handle_request($params);
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment