Ok, i have this $number which would equal a date in this format 2007-02-13 What i am trying to do is remove the - and 0's from the date so it would equal 27213 This is what i have but its not working: $number = number_format($number); $number = strpos($number, "0") ; Please advise
Why not use str_replace? $number = str_replace( '-', '', $number ); $number = str_replace( '0', '', $number );
<?php $number = "2007-02-13"; $number = str_replace("0", "", $number); $number = str_replace("-", "", $number); echo $number; // result "27213" ?> good luck
FYI you can use arrays for str_replace, makes slightly more efficient code ... $number = str_replace( array("0", "-"), array("", ""), $number ); PHP:
Yet on another sidenote, the second argument doesn't need to be an array. If it's a string all items in the first array will be replaced with it. So this would work too. $number = str_replace( array("0", "-"), "", $number ); PHP: