I have an associated array that has data pushed on it as below
$extradata = array()
$array['data'] = 'here';
$array[extra'] = 'or there';
array_push($extradata, $array)
$array1['data1'] = 'here1';
array_push($extradata, $array1)
Then further on eval() is used to insert the data in to the relevant part of a string. the string would be made of a few blocks of xhtml as below
$block1 = "<div>$data $extra</div>";
$block2= "<div>$data1</div>";
$block = $block1.$block2;
then further down the the php vars $data and $data1 a inserted into the string. The problem is that when there are mutliple php $data vars it doubles up so instead of seeing
<div>here or there</div>
<div>here1</div>
I get
<div>here or there</div>
<div>here or there</div>
<div> </div>
<div>here1</div>
So does anyone have any ideas of what to change to the loops below to stop the duplication
foreach ($extradata as $extradataitem){
// go through list of php vars
foreach($extradataitem as $key=>$val){
$var = $key;
$$var = $val;
}
$partialblock = $block;
$evalresult = eval("\$partialblock = \"$partialblock\";");
$output.= $partialblock;
}
eval() problem / associated array
Moderator: General Moderators
-
ricardoz999
- Forum Newbie
- Posts: 1
- Joined: Tue Nov 18, 2008 11:38 pm