0

I need to add 2 numbers together.

$num1 = 40;
$num2 = 20;

$num12 = $num1 + ':' + $num2;

For some reason this outputs as 60 and it should be 40:20.

is there some way to format this?

2 Answers 2

2

yes there is. use php concatenation (.) not javascript concatenation (+).

$num12 = $num1 . ':' . $num2;
Sign up to request clarification or add additional context in comments.

Comments

0

What you are looking for is string concatenation.

In php you need the .-operator , not the +:

$num12 = $num1 . ':' . $num2;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.