note 91255 added to function.str-replace
| From: | (gmailalso@yahoo.com) | Date: | Tue, 02 Jun 2009 11:13:34 +0000 |
| Subject: | note 91255 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156279@lists.php.net to get a copy of this message | ||
<?php
//convertion text
$line = "Today's temperature is 28^0 C. 1.5E14 is a double value.";
$line .= " 1.5e14 also a double value. H2O, CO2";
if(ereg("H2O",$line))
$line=str_replace("H2O","H<sub>2</sub>O",$line);
if(ereg("CO2",$line))
$line=str_replace("CO2","CO<sub>2</sub>",$line);
if(ereg("[0-9]E[0-9]",$line) ||
ereg("[0-9]e[0-9]",$line) || ereg("^",$line))
{
$exponents = explode(" ",$line);
foreach($exponents as $exponent)
{
if(ereg("[0-9]E[0-9]",$exponent)) {
$exp = explode("E",$exponent);
$line=str_replace("$exp[0]E$exp[1]",
"$exp[0]x10<sup>$exp[1]</sup>",$line);
}
if(ereg("[0-9]e[0-9]",$exponent)) {
$exp = explode("e",$exponent);
$line=str_replace("$exp[0]e$exp[1]",
"$exp[0]x10<sup>$exp[1]</sup>",$line);
}
if(ereg("^",$exponent)) {
$exp = explode("^",$exponent);
$line=str_replace("$exp[0]^0","$exp[0]°",$line);
}
}
}
echo $line;
?>
Today's temperature is 28° C. 1.5x1014 is a double value. 1.5x1014 also a double value. H2O,
CO2
----
Server IP: 69.147.83.197
Probable Submitter: 58.65.224.5
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/91255
Del: integrated -- https://master.php.net/note/delete/91255/integrated
Del: useless -- https://master.php.net/note/delete/91255/useless
Del: bad code -- https://master.php.net/note/delete/91255/bad+code
Del: spam -- https://master.php.net/note/delete/91255/spam
Del: non-english -- https://master.php.net/note/delete/91255/non-english
Del: in docs -- https://master.php.net/note/delete/91255/in+docs
Del: other reasons-- https://master.php.net/note/delete/91255
Reject -- https://master.php.net/note/reject/91255
Search -- https://master.php.net/manage/user-notes.php