PHP function to automatically output the select form

WBOY
Release: 2016-07-25 08:58:03
Original
1382 people have browsed it
This article introduces a function that uses PHP to automatically output (construct) a select form. Friends in need can refer to it.

The following functions are implemented: Automatically generate select options.

The code is as follows:

$item){ $str_sel=""; if($key==$msg_val) $str_sel=" selected"; $str_return.=""; } }else{ foreach($arr_list as $item){ $str_sel=""; if($item==$msg_val) $str_sel=" selected"; $str_return.=""; } } return $str_return; } ?>
Copy after login

Code description: Returns a select option item, $msg_list is an array ($key=>$value), $msg_val is the value that needs to be selected by default. The function can be written as a static method in a PHP static class, which is more convenient to use.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!