It's a bad practice to interpolate string this way because it makes the code very difficult to read, so you should rather use "{$h}"
instead of "$h"
.
As Terminus mentioned in comments, depending on the PHP version,
echo "$ca_1[remaining_time]"
Does not necessarily give a
PHP Notice: Use of undefined constant
Like echo $ca_1[remaining_time]
would. But since that didn't work for you, you'd better quote that like ['remaining_time']
.
You might also find some interesting things on this topic here.
Second, use curvy braces to explicitly tell what you want to insert:
$contents[11] = "$hours:$minutes:$seconds\n{$ca_1['remaining_time']}\n$h:$m:$s";
This really improves readability.