Jump to content

Array values as variables


LiLaaron

Recommended Posts

Hi There!

I am basically trying to get the value of the array only and make it a variable.

First my Code:

[code]
<?
$text = file_get_contents("../ez_sql.php");
preg_match_all('/define\s*\(([^,]+),([^\)]+)\)/i', $text, $matches);
foreach($matches[1] as $key => $value)
{
   $value = trim(trim($value), '\'"');
   $data[$value] = trim(trim($matches[2][$key]), '\'"');
}
// show results:
foreach($data as $key => $value)
{
  echo "<p>Key: $key, Value: $value !</p>\n";
}
?>
[/code]

This will show me 18 different defines ($keys) what i need is the first 5 values as variables so it may look like this:


[code]
$username = $value[1];
$password = $value[2];
$dbname = $value[3];
$server = $value[4];
$prefix = $value[5];
[/code]

i would then do what i need to do with them, just i am finding it hard to make the value a variable.

Thanks
Aaron
Link to comment
Share on other sites

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.