Skip to main content
12 events
when toggle format what by license comment
Aug 16, 2015 at 21:04 comment added CTS_AE Let us continue this discussion in chat.
Aug 16, 2015 at 21:04 comment added CTS_AE I just switched the parameters around so that default is the first parameter, thus if nothing is set with any amount of parameters it will always grab the first parameter as the default. Yeah I've heard talk about PHP 7 being out and was just wondering if it introduced something to help with this issue ;) I'm not sure if the if($argCount < 3) short circuit is a shortcut that will save time, you could always strip it out and just have the for loop in the function. Last I remember the passing by reference was important for arrays and invalid indexes.
Aug 16, 2015 at 20:59 history edited CTS_AE CC BY-SA 3.0
updated the code and parameter arrangement
Aug 16, 2015 at 20:59 comment added pronebird You can drop else statement completely and just leave isset($isset) ? $isset : $default;. PHP 7 solves that disaster with ?? operator.
Aug 16, 2015 at 20:57 comment added CTS_AE @Andy unfortunately there's no way to pass any given amount of parameters all as reference from what my last research concluded.
Aug 16, 2015 at 20:55 comment added pronebird Too bad this won't work for multiple arguments. it throws a notice when calling getDefault with bunch of non-existing variables, apparently because only the first argument is passed by ref.
Aug 16, 2015 at 20:55 history edited CTS_AE CC BY-SA 3.0
Updated code changes
Aug 16, 2015 at 20:53 comment added CTS_AE @Andy that's a good point I'm sure my updated code would include that so I will update this answer to include that; good catch : ) It's been a while since I wrote this so I'm not sure if I had a reason but that's also a good catch I will update ; )
Aug 16, 2015 at 10:12 comment added pronebird Return is missing in else statement. Why do you start loop from 2nd argument?
S Jan 29, 2014 at 3:23 review Late answers
Jan 29, 2014 at 5:21
S Jan 29, 2014 at 3:23 review First posts
Jan 29, 2014 at 5:14
Jan 29, 2014 at 3:07 history answered CTS_AE CC BY-SA 3.0