Jump to content

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.
Link to comment
https://forums.phpfreaks.com/topic/23304-explain-what-this-does/
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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.