note 46744 deleted from function.func-get-arg by danbrown

From: Date: Fri, 06 Feb 2015 21:35:48 +0000
Subject: note 46744 deleted from function.func-get-arg by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201662@lists.php.net to get a copy of this message
Note Submitter: dvogel at ssc dot wisc dot edu ---- I've always wants a deferment or cascade operator so that I could use this expression: $a = $b ## $c ## $d; and everything to the right of the assignment operator would evaluate to the left-most value that is not null. It is essentially a collapsed version of this: <?php if ($b) { $a=$b; } else { if($c) { $a=$c; } else { if ($d) { $a = $d; } else { $a = null; } } } ?> In leiu of this, I'm trying to make a function that takes a variable number of arguments and returns the first that is not null. I wan't to use this on some large-ish arrays, so I'd like to pass these by reference. However, call-time reference passing is disabled (and should be, imo) in newer versions of PHP. I'd like suggestions on how to pass both references and values to this function. The only solution I can think of is setting variables to the reference of the array first. e.g. $a = array( ... ); $b = 0; $c = &a; first_not_null($a, $b); Does anyone know a better solution?

« previous php.notes (#201662) next »