php 换行 空格分割处理

				<?php 
	        		function parse_specification($specification){
	        			$rt=array();
	        			$lines=array_filter(preg_split("/[
]/",$specification));
	        			foreach($lines as $line){
	        				$fields=array_filter(preg_split("/[s]+/",$line));
	        				if(count($fields)>1){
	        					$rt[]=array('k'=>array_shift($fields),'v'=>join(' ',$fields));
	        				}
	        			}
	        			return $rt;
	        		}
	        		$specification = trim($product['specification']);
	        		if(!empty($specification)){
	        			$specification = parse_specification($specification);
	        		}
        		?>
原文地址:https://www.cnblogs.com/andydao/p/5012064.html