note 108430 added to function.str-replace

From: Date: Wed, 25 Apr 2012 20:41:58 +0000
Subject: note 108430 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-187345@lists.php.net to get a copy of this message
In many countries the numeric format is 1.000,33 in english it is 1,000.33 This function converts numeric arguments always into the PHP confirm numeric format. If only one seperator is into the numericstring so it is interpreted as the decimalpoint. function dp($zahl) { if ((strpos($zahl,".") > "-1") | (strpos($zahl,",") > "-1")) { if ((strpos($zahl,".") > "-1") & (strpos($zahl,",") > "-1")) { if (strpos($zahl,".") > strpos($zahl,",")){ return str_replace(",","",$zahl); } else { return str_replace(",",".",str_replace(".","",$zahl)); } } else { if (strpos($zahl,".") > "-1") { if (strpos($zahl,".") == strrpos($zahl,".")) { return $zahl; } else { return str_replace(".","",$zahl); } } else { if (strpos($zahl,",") == strrpos($zahl,",")) { return str_replace(",",".",$zahl); } else { return str_replace(",","",$zahl); } } } } else { return $zahl; } } ---- Server IP: 69.147.83.197 Probable Submitter: 217.224.55.25 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/108430 Del: integrated -- https://master.php.net/note/delete/108430/integrated Del: useless -- https://master.php.net/note/delete/108430/useless Del: bad code -- https://master.php.net/note/delete/108430/bad+code Del: spam -- https://master.php.net/note/delete/108430/spam Del: non-english -- https://master.php.net/note/delete/108430/non-english Del: in docs -- https://master.php.net/note/delete/108430/in+docs Del: other reasons-- https://master.php.net/note/delete/108430 Reject -- https://master.php.net/note/reject/108430 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187345) next »