Link to home
Start Free TrialLog in
Avatar of lfirth1959
lfirth1959Flag for Australia

asked on

Concatenation a string

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.
ASKER CERTIFIED SOLUTION
Avatar of Barthax
Barthax
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial