ereg (Why, Does sort of work)?

From: Date: Sun, 03 Nov 2002 03:03:46 +0000
Subject: ereg (Why, Does sort of work)?
Groups: php.general 
Request: Send a blank email to php-general+get-122539@lists.php.net to get a copy of this message
I'm comparing the values of a check box, against another form field, and it sort of works, but I don't understand why (A better solution? is listed below it? TIA, David Jackson --------------------------- And part of the HTML Form: --------------------------- <td><b>Account Type:</b></td> <td>Asset</td><td><input type="radio" name="transid" value="1000"></td> <td>Liability</td><td><input type="radio" name="transid" value="2000"></td> <input type="text" name="coa_acct" size="5" maxlength="5"> ---------------------------------- Here's the one that's puzzling me: ---------------------------------- if ( ereg("^1",$_POST['transid'])== ereg("^1",$_POST['coa_acct'])): echo $_POST['coa_acct']; else : echo "Get off you Asset!"; exit; endif; --------------------------------------- The "better" solution using substrings? --------------------------------------- if ( substr($_POST['transid'],0,1)== substr($_POST['coa_acct'],0,1)): echo $_POST['coa_acct']; else : echo "Get off you Asset!"; exit; endif;

« previous php.general (#122539) next »