我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

将字符串拆分为数组并更改密钥名称

I'm trying to split a string into an array where I can set the keyname instead of 1 2 3.

Here's the string:

"id=1&day=4&month=12&status=3"

The string can be just the ID, the ID and day, or all 4 together.

I want it to be like this:

array([id] => 1 [day] =>4...) 

Use parse_str():

parse_str("id=1&day=4&month=12&status=3", $parts);
var_export($parts);

Demo

近期文章

  • 未找到“smtpTransport”类
  • 台式PC或服务器作为Web服务器
  • PHP使用抽象类或接口?
  • 有没有办法让界面方法添加body?
  • CodeIgniter重定向方法不起作用
  • Php回显html div无法正常工作[关闭]
  • Laravel重定向和验证逻辑
  • 用sqlite和laravel eloquent测试phpunit
  • PHP; 从函数内部报告错误
  • 使用AJAX和重定向将表单值传递给PHP变量
  • 图片上传到谷歌桶云存储
  • laravel“csrf”问题“Illuminate \ Session \ TokenMismatchException”
  • 使用Instagram API将标记端点与用户端点结合使用
  • Doctrine \ ORM \ Query \ QueryException [语义错误] ...:错误:未定义类'NULL'。 在QueryBuilder中使用NULL时
  • 无法从我的网站访问MySQL数据库,但可以通过浏览器访问?
  • 从三个表中选择
  • 加入数据库和计数
  • Php在构造函数中创建对象[关闭]
  • 同时从2个表中删除
  • id in where子句未定义的索引

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华