Jump to content

Concatenation Problem


smti

Recommended Posts

Hello,

 

I am trying to put 3 strings together separated by slashes. (It's a date field), but when I output the end result I see something like this: 01/200725/2007 Does anyone know why?

 

Here is my code:

 

//Grab Separate Date Values for Admission Date

$doamonth=$_REQUEST['doamonth'];

$doaday=$_REQUEST['doaday'];

$doayear=$_REQUEST['doayear'];

 

 

//Put date values together

$slash='/';

$doa=$doamonth .=$slash .=$doaday .= $slash .=$doayear;

 

echo $doa;

 

The result is something like this: 01/200725/2007 if I input the date as such: 01/25/2007 (using month/day/year format.)

 

Thanks for your help!

 

- smti

 

Link to comment
https://forums.phpfreaks.com/topic/99705-concatenation-problem/
Share on other sites

You're syntax is all wrong. Do:

<?php
//Grab Separate Date Values for Admission Date
$doamonth=$_REQUEST['doamonth'];
$doaday=$_REQUEST['doaday'];
$doayear=$_REQUEST['doayear'];


//Put date values together

$doa=$doamonth . '/' . $doaday . '/' . $doayear;
echo $doa;
?>

or

<?php
//Grab Separate Date Values for Admission Date
$doamonth=$_REQUEST['doamonth'];
$doaday=$_REQUEST['doaday'];
$doayear=$_REQUEST['doayear'];


//Put date values together

$doa="$doamonth/$doaday/$doayear";
echo $doa;
?>

 

Ken

 

Link to comment
https://forums.phpfreaks.com/topic/99705-concatenation-problem/#findComment-510052
Share on other sites

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.