Skip to content

Instantly share code, notes, and snippets.

@kelchm
Created February 25, 2016 19:06
Show Gist options
  • Save kelchm/620f6920b86cc6fdfa54 to your computer and use it in GitHub Desktop.
Save kelchm/620f6920b86cc6fdfa54 to your computer and use it in GitHub Desktop.
<?php
class Helper {
static function getIfSet(& $var) {
if (isset($var)) {
return $var;
}
return null;
}
}
// Test Values
$testValues = array(
'foo1' => '123',
'foo2' => '123',
);
$newArray = array(
'foo1' => Helper::getIfSet($testValues['foo1']),
'foo2' => Helper::getIfSet($testValues['foo2']),
'foo3' => Helper::getIfSet($testValues['foo3']),
);
print_r($newArray);
?>
@robehickman
Copy link

Really don't need a class here, it's just a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment