php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #23768 Create an smart if that will return value of the parameter that matches expr
Submitted: 2003-05-22 23:32 UTC Modified: 2003-05-23 02:10 UTC
From: mno11 at lycos dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.1 OS: Windows XP
Private report: No CVE-ID: None
 [2003-05-22 23:32 UTC] mno11 at lycos dot com
While using PHP and many other programming languages, I've come across having to use the following code a lot:

if (strlen($form_fields[$i]) > $cur_max)
   $cur_max = strlen($form_fields[$i]);

It would be great if PHP had a smart if_replace function implemented that will return the value of first parameter passed if expression is true and value of second parameter passed if expression is false.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-23 02:10 UTC] sniper@php.net
In almost every language there is ternary operator,
also in PHP:

http://www.php.net/manual/en/language.operators.comparison.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jun 01 00:01:26 2025 UTC