Home > php教程 > php手册 > 提取二维数组中的值作为where in 的条件

提取二维数组中的值作为where in 的条件

WBOY
Release: 2016-06-06 19:31:35
Original
1054 people have browsed it

无详细内容 无 /** * 获取二维数组中的一维键值,主要用于 sql in 或者 not in 操作 * @param 数组 $data * @param 键值 $field * @param 分隔符 $sperator * @author */ function getKeyStr($data,$field,$sperator=',') { $str = $dot = ''; if (empty($dat

 /**
  * 获取二维数组中的一维键值,主要用于 sql in 或者 not in 操作
  * @param 数组 $data 
  * @param 键值  $field
  * @param 分隔符 $sperator
  * @author 
  */
 function getKeyStr($data,$field,$sperator=',')
 {
 	$str = $dot =  '';
 	if (empty($data) || !is_array($data) || empty($field)) return $str;
 	foreach ($data as $key=>$value)
 	{
 		if (array_key_exists($field, $value) && !empty($value[$field]))
 		{
 			$str .= $dot.$value[$field];
 			$dot = $sperator;
 		}
 		
 	}
 	return $str;
 }
Copy after login
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template