欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal form 跳转

shiping1 的头像
function caiji_list_form_submit($form, &$form_state) {
    $list_url = $form_state['values']['list_url'];
    $list_start = $form_state['values']['list_start'];
    $list_end = $form_state['values']['list_end'];
    $list_remove = $form_state['values']['list_remove'];

    $content = file_get_contents($list_url);
    !empty($list_start) &&  $content = stristr($content,$list_start);
    !empty($list_start) && $content = substr($content,0,stripos($content,$list_end));

    preg_match_all('/<a(.*)href=["\']([^>]+)["\'](.*)>/misU',$content,$out,PREG_PATTERN_ORDER);

    $contentStr = "<div><ol>";
    foreach($out[2] as $key=>$value){
        $contentStr .= "<li style=\"color:#f00\">".$value."</li>";
    }
    $contentStr .="</div></ol>";

    $content = $contentStr;
    //保存内容的文件
    _saveFile(dirname(__FILE__). '/caijicontent.txt', $content);


    $contentJson = _my_json_encode($out[2]);
    //保存json格式的文件
    _saveFile(dirname(__FILE__). '/caijicontentjson.txt', $contentJson);
    //这里是跳转
    $form_state['redirect'] = 'caiji?list=list_url='. $list_url.'&&&list_start='.$list_start.'&&&list_end='.$list_end.'&&&list_remove='.list_remove;
}
普通分类: