troubleshooting Question

Concatenation a string

Avatar of lfirth1959
lfirth1959Flag for Australia asked on
2 Comments2 Solutions934 ViewsLast Modified:
I am new to PHP and am used to ASP, what would work on ASP dousn't seem to in PHP

I am developing an application that produces a pdf invoice. I am trying to concatenate a string with the result of a recordset field like so:

$phone = 'PH '.phoneNum($row_rsBusiness['Phone']);

The function phoneNum just adds spaces to a 10 digit number to make it more readable.

function phoneNum($string) {
      $pattern = '/(\d{2})(\d{4})(\d{4})/';
      $repl = '$1 $2 $3';
      echo preg_replace($pattern, $repl, $string );

The problem is they don't concatenate, the phone number just prints to the screen.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros