I want to concatenate 3 strings. For first string I am splitting it to get first 4 letters. Another is user_name
and the last is date_of_application
.
we use .
(dot operator) in PHP. But as I am doing in this, In result first two strings are concatenated well but third i.e. date_of_application
, only first 2 or 4 letters are getting concatenated not the whole string.
$this-> member_id = mb_substr($this->country, 0, 4) . $this->user_name . $this->date_of_application;
Input:
28/08/2016,28082016
results:
Indisid128/0, Indisiddhi28
EDIT:
I want to get the digits from date.Input date can be in any format. For example- if input date is 28 Aug 2016. The output should be concatenated string _ 28082016. How can I get this?
What's going wrong?
You can not concatenate date
with string
with your existing format. You need to convert it (slashes are removed).
Write date('Y_m_d-H-i-s', strtotime($this->date_of_application));
Write your code as below:
$country = mb_substr($this->country, 0, 4);
$username = $this->user_name;
$converted_date = date('Y_m_d-H-i-s', strtotime($this->date_of_application));
$this->member_id = $country . $username . $converted_date;