Jump to content

Archived

This topic is now archived and is closed to further replies.

avo

Symbol

Recommended Posts

Hi All

What is the use of

[quote]$$[/quote]

for example in

[code]$amount=$amount + $$s * $a_addtime[$i];[/code]

thanks in advance

Share this post


Link to post
Share on other sites
I have never seen a double $ used like that. The only time I can think of two $ being used next to each other is if you echoing a US price next to a variable:

[code]<?php
$price = "100.00";
echo "The price is \$$price";
?>[/code]

Share this post


Link to post
Share on other sites
A variable like that is a variable variable. Please see http://www.php.net/manual/en/language.variables.variable.php

Ken

Share this post


Link to post
Share on other sites
HI thanks i was looking for a date function and found this

works good but i was just curious on what $$ did

[code]function timechange($starttime, $addtime, $add = true) {
        $min = 60;
        $hour = $min * 60;

        $a_time = array('hour', 'min', 'sec');
        $a_addtime = explode(':', $addtime);
        $amount = 0;
        for ($i = 0; $i < count($a_addtime); $i++) {
                $s = $a_time[$i];
                $amount += $$s * $a_addtime[$i];
        }

        $starttime = strtotime($starttime);
        $s = ($add === true) ? date('H:i', $starttime + $amount) : date('H:i', $starttime - $amount);
        return $s;
}[/code]

This will add time to time

[quote]echo timechange('20:50', '01:40');[/quote]

This will minuss time from time

[quote]echo timechange('20:50', '01:40', false);[/quote]

if anyone would like it

Still currious.. ???

Share this post


Link to post
Share on other sites
Thanks Ken  :)

Share this post


Link to post
Share on other sites
Wow thanks Ken, I didnt know that.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.