时间:2021-07-01 10:21:17 帮助过:6人阅读
- <br><!--?php <BR-->/** <br>* transform ' hello, world !' to array('hello', 'world') <br>*/ <br>function strsToArray($strs) { <br>$result = array(); <br>$array = array(); <br>$strs = str_replace(',', ',', $strs); <br>$strs = str_replace("n", ',', $strs); <br>$strs = str_replace("rn", ',', $strs); <br>$strs = str_replace(' ', ',', $strs); <br>$array = explode(',', $strs); <br>foreach ($array as $key => $value) { <br>if ('' != ($value = trim($value))) { <br>$result[] = $value; <br>} <br>} <br>return $result; <br>} <br>//test <br>$strs = 'Code is poetry! WTF!'; <br>var_dump(strsToArray($strs)); <br>
- <p></p>
- <p align="left"><span id="url" itemprop="url">http://www.bkjia.com/PHPjc/325599.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/325599.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">我们在搜索一些东西时会经常遇到可以通过空格隔开来达到输入多个条件的目的。今天正好项目中遇到了这个情况,就写了一个函数,将多...</span></p>