Jump to content

Recommended Posts

I've "scraped" some data from one of my other sites and need to assign dynamically increasing variables:

 

Heres some sample code.  In the end, each output row will have

 

$variable1 = $k . " " . $v;

$variable2 = $k . " " . $v;

etc...

 

$data = @file_get_contents("https://XXX/index.php?inputEmailHandle=XXX", "r");  ;

preg_match_all('/<input.*?name="([^"]*)".*?value="([^"]*)"/is',$data,$out);

$d = array_combine($out[1], $out[2]);

//$insert_into = array();

foreach($d as $k=>$v){

echo $variablevariable . " = " . $k . " = " . $v . "<br>";

}

 

Link to comment
https://forums.phpfreaks.com/topic/118150-variable-variables/
Share on other sites

Example of variable variable

$str = 'hello';

${$str . 'world'} = 'hi';

echo $helloworld; // outputs hi

 

In your case you'll need to implement a counter. However it'll be better to use an array instead (after all this is what their there for)

Link to comment
https://forums.phpfreaks.com/topic/118150-variable-variables/#findComment-607864
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.