| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2003-04-26 09:38 UTC] helly@php.net
  | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 15:00:01 2025 UTC | 
It would be great if there was some method of PHP storing the last matched if condition. Allow me to demonstrate. ; --- Example $myarray = array( 'this' => 'test', 'that' => 'fun', ); if ($myarray['this'] == 'test') { echo('The value is '.$myarray['this']); } Now, I'm suggesting something like $ifmatch (easy name) and it would work like so. $ifmatch retains the first condition of an if () / elseif() that has matched (it's TRUE) like so: if ($myarray['this'] == 'test') { echo('The value is '.$ifmatch); } Where $ifmatch = 'test' (or, $array['this'] if you prefer) You might wonder what the advantage is? Well, I think it's a lot easier and more functional to do this: if ($myarray['this'] == 'test') { echo('The value is '.$ifmatch); } Then: if ($myarray['this'] == 'test') { echo('The value is '.$myarray['this']); } Or: $blah = $myarray['this']; if ($blah == 'test') { echo('The value is '.$blah); } I'm sure a lot of people could find use for this in the future. Also, I'm not sure if this is a bug or not, but, the Manual says is_null() handles mixed variables, however, this returns false: $test = NULL; $blah = NULL; echo((is_null($test,$blah) ? 'Yep' : 'Nope')); This was tested on 2k with the standard Windows lastest version of PHP and Apache 1.3.x (last stable) If is_null() can handle only 1 argument, please extend it for infinite args, I have coded my own routine for this but obviously PHP's internal would be faster. Last, but not least, PHP is probably my favorite language, more so then C/C++, please keep up the good work, it's truely a fantastic language and you have all done a fantastic job with it (coders, documentation team, web team) ;-) Thanks.