im triying to add dash in the phone numbers when added, the phone numbers are added complete without spaces. like: 1234567890, and i want the output to be:
123-456-7890
Depending on where the number is from it will change, for ex.:
Italy is: +391234567890 (+39-123-456-7890)
Spain is: +34123456789 (+34-123-45-67-89)
and so on.
this is the code im triying to add it to:
<div class="btn-group btn-group-sm" role="group" aria-label="Extra-small button group">
<a class="client_copy btn btn-gold"
data-client-name="<?php echo $emp['client_name']; ?>"
data-Client-email="<?php echo $emp['id_clients']; ?>"
data-client-phone="<?php echo $emp['phone_no']; ?>"
data-client-id="<?php echo $emp['ID']; ?>"
data-client-group="<?php echo $emp['group_name']; ?>"
data-client-city="<?php echo '$' . $emp['myprice']; ?>"
data-client-paymentmethod="<?php echo $emp['payment_method_name']; ?>"
data-client-paymentvia="<?php echo $emp['payment_via_name']; ?>"
data-client-paymentdetail="<?php echo $emp['payment_detail']; ?>"
data-client-paymentdate="<?php echo $emp['payment_date']; ?>"
data-client-customprice="<?php echo $emp['custom_price']; ?>"
href="#modalCopyClient"><i class="fa fa-files-o"></i></a>
So, the phone part is:
data-client-phone="<?php echo $emp['phone_no']; ?>"
i tried a couple solutions posted here but i coulndt make it work
one of them was to add:
echo '('.substr($data, 0, 3).') '.substr($data, 3, 3).'-'.substr($data,6);
that may be the solution but it didnt work for me, i ended having an error
i add it this way:
data-client-phone="<?php echo '('.substr($data, 0, 3).') '.substr($data, 3, 3).'-'.substr($data,6); $emp['phone_no']; ?>"
and had this error:
i know the error might be obvious but i just dont know that much about coding. sorry.
thanks!