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

WBOY
Release: 2016-06-23 14:06:03
Original
1004 people have browsed it

数据表的结构为下图


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

nsk-aaa 0F,MP-00A00 IO-000

nsk-aaa 0F,MP-00A00 F0-000

nsk-aaa 1F,MP-00A00 SA-000

依此类推。。

如果$a=nsk-aaayb,输出

nsk-aaa 0F

nsk-aaa 0F

nsk-aaa 1F

依此类推。。

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


回复讨论(解决方案)

$query=mysql_query("select * from table"); while ($row = mysql_fetch_array($query)) {    if(is_array($a)) {        echo 'nsk-aaa'.$row['darfon'].',MP-00A00'.$row['chicony'].'-000';    } else if(is_string($a)) {        echo 'nsk-aaa'.$row['darfon'];    }}
Copy after login


是这个意思么。。。

$a有多种可能
值的格式都是NSK-FFF FF,和MP-FFF FF-FFF,可能两个值都有,可能只含有NSK-FFF FF或者MP-FFFFF FF-FFF,需要替换的位置就是我标红的位置,还请老兄费神一把

PHP code?123456789$query=mysql_query("select * from table");  while ($row = mysql_fetch_array($query)) {    if(is_array($a)) {        echo 'nsk-aaa'.$row['darfon'].',MP-00A00'.$row['chico……

方法不是有了么?自己改下啊。。。

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 Tutorials
More>
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!