hi, I want to replace the date with “0000-00-00” to " ". the code below replaces field regardless
of value. please advise. thanks
if (str_replace(array('0','-',':'),"000-00-00 00:00") == '')
{
$row['duedate']='';
}
hi, I want to replace the date with “0000-00-00” to " ". the code below replaces field regardless
of value. please advise. thanks
if (str_replace(array('0','-',':'),"000-00-00 00:00") == '')
{
$row['duedate']='';
}
Hello!
I don’t really understand your question.
Here, I rewrote your code so it’s more readable:
$searchAr = array('0','-',':');
$newValue = "000-00-00 00:00";
if ( str_replace( $searchAr, $newValue ) == '')
{
$row['duedate']='';
}
The method definition of str_replace is
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
Meaning “search the values of $search in $subject and replace it with $replace”.
Your code seems to say “search the values of $searchAr and replace it with $newValue in…”
I think there is a parameter missing there… no?
You want to replace what with what in what?
Thanks a lot. Here is my working code:
$row[‘duedate’] = preg_replace(‘/[1]*$/’, ‘’, $row[‘duedate’]);
0:- ↩︎
you just forgot something like this
if(str_replace(array(‘0’,‘-’,‘:’),’ ‘,$row[‘duedate’])==’ ‘);
{
$row[‘duedate’]=’';
}
Thanks for your help