ryanb4614 ryanb4614 - 1 month ago 5
PHP Question

How do I add additional Text and Spaces in PHP

I am not very good with php I have the following line

$totaltime = $hours . ':' . $minutes;


Where the ':' appears I would like to have a hours I tried
' hours ' and it shows up in the front end fine, but I would also likes to add "minutes" Currently shows as 00 hours 00 I would to add minutes to the last 00

Answer

This sounds like what you are looking for:

$totaltime = $hours . ' hours ' . $minutes . ' minutes';

With apologies if you already know the following -

$ indicates variables - there are three variables - $totaltime, $hours and $minutes.

. is the concatenation operator, which adds the strings together.

Every line must end with a semicolon ;.

Strings may be encapsulated with single or double quotes. If you use single quotes, you will get exactly what you see. If you use double quotes, you may embed variables.

Comments