Hi Everyone,
How can I add a + sign to the following string.... for some reason I just can not figure it out
I have tried ".+
and ".+."
and sign quotes - both options but it just doesnt seem to work for me....

$number = $Code."".substr( $mobnum, 0 );

So, number will be the international code of the country plus the sms text message
for example 4401234567890 for UK numbers
but for international numbers I am trying to add the + sign
So it reads +11234567890 for the US...

Hope someone can help & explain where I am going wrong
Thanks

You should just be able to do this:

$number = '+' . $Code."".substr( $mobnum, 0 );

If you're just looking to add a plus sign at the beginning of a sequence of numbers, then it's as simple as the following:

$number = 1234567890;
$complete_number = "+" . $number;

Just ensure the + sign is inside the quotation marks.

Sorry if that's not what you're looking for, it's hard to tell from your code since I don't know the values of the variables.

Member Avatar for LastMitch

@DaveyMoyes

Hope someone can help & explain where I am going wrong

You didn't do anything wrong. It's just that + sign is to used for international call. It's pretty expensive.

Instead of this ".+ or this ".+." used "{+}"

Try this:

    $number = $Code."{+}".substr( $mobnum, 0 );
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.