当前位置:网站首页>PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
2022-07-02 05:49:00 【Jill__ er】
Original string
SystemStatus_View_1.00
Results show :
/*
array(2) {
["version"]=>
string(4) "1.00"
["code"]=>
string(17) "SystemStatus_+_View"
}
*/
<?php
/**
* function : Split string SystemStatus_View_1.00, according to _ Take out the last part 1.00;
* And the remaining parts are spliced into SystemStatus_+_View
*/
define('SYSTEMSTATUS_VIEW', 'SystemStatus_View_1.00');
function strFun($str)
{
$ret = array();
if($str){
$tmp = explode('_', $str);
var_dump($tmp);
/*
array(3) {
[0]=>
string(12) "SystemStatus"
[1]=>
string(4) "View"
[2]=>
string(4) "1.00"
}
*/
echo count($tmp); //3
if(preg_match('/\d+.\d+/', $tmp[count($tmp)-1]))
{
$ret['version'] = array_pop($tmp); //array_pop() Function to delete the last element in the array
$ret['code'] = implode('_+_', $tmp); //implode() Function returns a string composed of array elements . Group elements into a string
}
}
return $ret;
}
var_dump(strFun(SYSTEMSTATUS_VIEW));
?>
边栏推荐
- Grbl software: basic knowledge of simple explanation
- [Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
- Alibaba: open source and self-developed liquid cooling data center technology
- all3dp. All Arduino projects in com website (2022.7.1)
- Zzuli:1061 sequential output of digits
- RGB 无限立方体(高级版)
- php父类(parent)
- RGB infinite cube (advanced version)
- Fabric. JS compact JSON
- Lantern Festival gift - plant vs zombie game (realized by Matlab)
猜你喜欢

《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记

Visual studio import

Balsamiq wireframes free installation
![[technical notes-08]](/img/52/0aff21b01ba7adbfcdb597d1aa85f9.png)
[technical notes-08]

brew install * 失败,解决方法

Vite打包后的dist不能直接在浏览器打开吗

With an amount of $50billion, amd completed the acquisition of Xilinx

2022-2-14 learning xiangniuke project - Section 6 displays login information

Oled12864 LCD screen

“简单”的无限魔方
随机推荐
Pytorch Basics
如何写出好代码 — 防御式编程指南
VSCode paste image插件保存图片路径设置
Fabric. JS iText set italics manually
中小型项目手撸过滤器实现认证与授权
OLED12864 液晶屏
1037 Magic Coupon
Ubuntu 20.04 installing mysql8
Vscode paste image plugin saves image path settings
5g market trend in 2020
软件测试基础篇
[PHP是否安装了 SOAP 扩]对于php实现soap代理的一个常见问题:Class ‘SoapClient‘ not found in PHP的处理方法
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond
测试 - 用例篇
Technologists talk about open source: This is not just using love to generate electricity
Financial portal related information
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
Straighten elements (with transition animation)
php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组