Re: From 24/7/2013 to 2013-07-24
| From: | Jim Giner | Date: | Fri, 26 Jul 2013 14:10:10 +0000 |
| Subject: | Re: From 24/7/2013 to 2013-07-24 | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321718@lists.php.net to get a copy of this message | ||
I think you should change from using 'rsort' ( a SORT function) to 'array_reverse', a simple reverse function.
Your example of what you desire is wrong.
24-7-2013 will give you the 2013-24-7 that you want.
Here is my sample code. Try it yourself.
<?
$dag = array("24/7/2013");
echo "Began with: ";var_dump( $dag);
echo "<br>**********<br>";
echo "Try using rsort<br>";
$dagparts = explode("/",$dag[0]);
echo "dagparts: ";
var_dump($dagparts);
echo "<br>**********<br>";
rsort($dagparts);
echo "sorted dagparts: ";
var_dump($dagparts);
echo "<br>**********<br>";
$newdag = implode("-",$dagparts);
echo "newdag: ";
var_dump($newdag);
echo "<br>**********<br>";
echo "Now use array_reverse<br>";
$dagparts = explode("/",$dag[0]);
echo "dagparts: ";
var_dump($dagparts);
echo "<br>**********<br>";
$dagparts = array_reverse($dagparts);
echo "REVERSED dagparts: ";
var_dump($dagparts);
echo "<br>**********<br>";
$newdag = implode("-",$dagparts);
echo "newdag: ";
var_dump($newdag);
echo "<br>**********<br>";