Home >Backend Development >PHP Tutorial > php怎么从数组中提取出包含不同字符串键值并循环替换返回一个新的数组

php怎么从数组中提取出包含不同字符串键值并循环替换返回一个新的数组

WBOY
WBOYOriginal
2016-06-13 12:48:12920browse

php如何从数组中提取出包含不同字符串键值并循环替换返回一个新的数组
数据表的结构为下图


如果$a=array(nsk-aaayb,MP-00A00uk-000),输出

nsk-aaa0F,MP-00A00IO-000

nsk-aaa0F,MP-00A00F0-000

nsk-aaa1F,MP-00A00SA-000

依此类推。。

如果$a=nsk-aaayb,输出

nsk-aaa0F

nsk-aaa0F

nsk-aaa1F

依此类推。。

还望哪位大侠帮解,先行谢过


------解决方案--------------------
<br />
<br />
$query=mysql_query("select * from table");<br />
 <br />
while ($row = mysql_fetch_array($query)) {<br />
    if(is_array($a)) {<br />
        echo 'nsk-aaa'.$row['darfon'].',MP-00A00'.$row['chicony'].'-000';<br />
    } else if(is_string($a)) {<br />
        echo 'nsk-aaa'.$row['darfon'];<br />
    }<br />
}<br />


是这个意思么。。。
Statement:
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