Jump to content

Archived

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

SharkBait

Explain what this does?

Recommended Posts

[code]
<?php
while (!feof($handle)) { # Checks the File pointer integer returned by fopen.
              $buf = fgets($handle, 1096); # Returns a String from config, 1098 bytes long.
              list($k,$v)=split('=', $buf); # Create a list of variables and assign string values by splittin$
              $v = trim($v); #Remove Whitespace from $V

            if ( $k ) {
                      $config{$k} = "$v";
            }
    #      echo "#" .$k .$v ."<br>";
    #      echo $config
}
?>
[/code]

Well the part I have not seen before is the line [code=php:0] $config{$k} = "$v";[/code]  I've never seen curley braces used on a variable. What is it for?

The rest of it I do understand.

Thanks.

Share this post


Link to post
Share on other sites
the {} when use with a variable means that the variable's name can be dynamic/set on the fly.

so:

[code]
<?php
$first = 'dog';
$second = 'cat';

$animal{$first} = 'woof';
$animal{$second} = 'miaw';

echo $animaldog;
echo $animalcat;
?>
[/code]

Share this post


Link to post
Share on other sites
Ah thats what I thought. But I've never seen it before until today. Thank you

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.