Hi all
Is it possible to have a function with two parameters but and then check if one is passed before using it.
In this code here I want to remove spaces and change to lowercase.
If the $extra parameter is set I want to add that to the end of the string.
function className($nametoUse, $extra){
$noSpace = str_replace(' ', '', $nametoUse);
$toLower = strtolower($noSpace);
if(!empty($extra)){
$classtoUse = $toLower." ".$extra;
}else{
$classtoUse = $toLower;
}
return $classtoUse;
}
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.