Jump to content

[SOLVED] Explode simple question


robert_gsfame

Recommended Posts

<?php $day = $_POST['day'];        ------------->09

  $month = $_POST['month']; ---------->02

  $year = $_POST['year'];--------------->2009

  $num= "/".$day."/".$month."/".$year; ---->09/02/2009

  //echo $num;

              explode("/",$num);

  echo $num[0];

    echo $num[1];

    echo $num[2];

 

?>

 

can anyone help me how to get result like this    "9022009"

Link to comment
https://forums.phpfreaks.com/topic/172668-solved-explode-simple-question/
Share on other sites

$num= "/".$day."/".$month."/".$year; ---->09/02/2009

 

Is

 

$num= "/".$day."/".$month."/".$year; ---->/09/02/2009

 

Then:

 

explode("/",$num);

 

Should be:

 

$num = explode("/",$num);//returns Array ( [0] => , [1] => 09, [2] => 02, [3] => 2009);

 

Remove the leading forward slash:

 

$num= $day."/".$month."/".$year; ---->09/02/2009

 

And you'll get:

 

$num = explode("/",$num);//returns Array ( [0] => 09, [1] => 02, [2] => 2009);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.