Re: note 26058 added to function.str-replace
| From: | Maxim Maletsky | Date: | Wed, 16 Oct 2002 15:39:05 +0000 |
| Subject: | Re: note 26058 added to function.str-replace | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-38171@lists.php.net to get a copy of this message | ||
You should be using explode() instead, split() works a little different:
function date2sapdb($date)
{
//$date = "06.04.2002";
list($day, $month, $year) = explode(".",$date);
$date = $year."-".$month."-".$day;
echo $date;
}
Your note will be removed.
--
Maxim Maletsky
maxim@php.net
dahund@gmx.net wrote... :
> I've used this function to translate a readable date string in ISO format for a SAPDB
system:
>
> function date2sapdb($date)
> {
> //$date = "06.04.2002";
> list($day, $month, $year) = split(".",$date,3);
> $date = $year."-".$month."-".$day;
> echo $date;
> }
>
> -> will output: ".04.2002--" huuuh? :(
>
> now i've replaced the "." with "-" and did the same split again. Now
it will work:
>
> function date2sapdb($date)
> {
> //$date = "06.04.2002";
> $date = str_replace(".","-",$date);
> list($day, $month, $year) = split("-",$date,3);
> $date = $year."-".$month."-".$day;
> echo $date;
> }
>
> -> will output 2002-04-06 - it work's :)
>
> Tested on Windows NT 5.0 build 2195 with Apache/1.3.23 (Win32) and PHP V4.1.1.
> Is it a bug/feature? - but i don't think so.
> --
> http://www.php.net/manual/en/function.str-replace.php
> http://master.php.net/manage/user-notes.php?action=edit+26058
> http://master.php.net/manage/user-notes.php?action=delete+26058
> http://master.php.net/manage/user-notes.php?action=reject+26058
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>