do you know how can i put a hyphen (-) after 3 digits of a number(starting from the end) in php? example: the number 9787897878 to be shown as 978-789-7878??
ramya_nd
0
Newbie Poster
Recommended Answers
Jump to PostSomething like this:
$subject = '9787897878'; $result = preg_replace('/(\d{3})(\d{3})(\d*)/i', '\1-\2-\3', $subject); echo $result;
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.