开发者

How to transform the email string to make the assignment a success using eval() in php

I want to use the eval function in php to perform the assignment operation, but the value is email address which contains '@'. How should I transform the 开发者_运维问答email string to make the assignment a success?


DON'T USE EVAL.

There is almost no problem or function for which eval() is the best answer, there is always another approach.

Consider using an associative array for your variables, then $data[$fieldname] = $email; will give you the ability to dynamically assign the email into a field.


foreach ($submittion->data as $key => $value) {
        $ele_key_array = webform_component_parent_keys($form['#node'], $form['#node']->webform['components'][$key]);
        $ele_key = "['" . implode("']['",$ele_key_array) . "']";
        $ele_value = implode(',', $value['value']);
        dsm($ele_value);
        @eval("\$form['submitted']" . $ele_key . "['#default_value']=$ele_value;");
    }

the codes are used in drupal to get the form key and set its default value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜