I appreciate all of the suggestions though I wasn't able to get any to work.
1
Quote:
$data['options']['array'] = array(0 => "opt1",
1 => "opt2",
2 => "opt3");
|
I'm probably missing the point but if I can't get the code to run through a regular array, how will changing it to a multiarray help?
2
Quote:
$fp[] = "foreach (array('" . implode(',\'', $data['options']) . "') as $option) {
Changed to the following to get it to not fail:
$fp[] = "foreach (array('" . implode(',\'', $data['options']) . "') as \$option) {" . "\n";
|
This almost worked. The output was
PHP Code:
foreach (array('opt1,'opt2') as $option) {
I only used two options to test the above. Is there a way to surround each member of the array in single quotes since that seems to be the problem with it?
3
Quote:
|
put the $data['options'] variable into the single quotes
|
I'm not sure what was meant by this but if you mean something like
PHP Code:
$fp[] = "foreach (\$data['options'] as \$field ) {" . "\n";
If I do that, the actual name shows in the output as
PHP Code:
foreach ($data['options'] as $field ) {
But that won't work since that array is not known in the created file.
4
Quote:
|
$fp[] = "foreach (@unserialize('" . str_replace('\'', '\\\', serialize($data['options'])) . "') as $option) {
|
I couldn't get this to run due to parsing errors. I changed it to the following but it still fails.
PHP Code:
$fp[] = "foreach (@unserialize(str_replace('\'', '\\', serialize(" . $data['options'] . ")) . ") as $option) {" . "\n";
I would apreciate any other suggestions.