$con = '2010年工资¥2000,2011年工资¥3000,2012年工资¥4000,2013年工资¥4500,2014年工资¥5000,2015年工资¥5000,2016年工资¥5500,2017年工资¥5500,2018年工资¥6000,2019年工资¥6500';
我现在需要把$con弄成数组,遍历插入数据库
insert info table_name (nian, gongzi) VALUES ($nian, $gongzi)
最终的数据库结果
id nian gongzi
1 2010 2000
2 2011 3000
3 2012 4000
4 2013 4500
5 2014 5000
............
请问这个过程PHP数组怎么处理?
这个php数组怎么处理?请教!
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 听楼一夜雨 2019-06-30 16:55关注
<?php header("Content-type: text/html; charset=utf-8"); $con = '2010年工资¥2000,2011年工资¥3000,2012年工资¥4000,2013年工资¥4500,2014年工资¥5000,2015年工资¥5000,2016年工资¥5500,2017年工资¥5500,2018年工资¥6000,2019年工资¥6500'; $info=array(); $data=explode(",",$con); echo "<pre>"; print_R($data); foreach ($data as $k=>$v){ $info[$k]['nian']=explode("年",$v)[0]; $info[$k]['gongzi']=explode(";",$v)[1]; } print_R($info); ?>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 微信会员卡等级和折扣规则
- ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
- ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
- ¥15 gdf格式的脑电数据如何处理matlab
- ¥20 重新写的代码替换了之后运行hbuliderx就这样了
- ¥100 监控抖音用户作品更新可以微信公众号提醒
- ¥15 UE5 如何可以不渲染HDRIBackdrop背景
- ¥70 2048小游戏毕设项目
- ¥20 mysql架构,按照姓名分表
- ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分