当前位置:网站首页>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));
?>
边栏推荐
- Zzuli:1064 encrypted characters
- h5跳小程序
- 2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
- Here comes a new chapter in the series of data conversion when exporting with easyexcel!
- Uva548 tree
- Financial portal related information
- Usage record of vector
- 1037 Magic Coupon
- Fabric. JS iText set italics manually
- idea开发工具常用的插件合集汇总
猜你喜欢

Basic use of form

vite如何兼容低版本浏览器

Installation du tutoriel MySQL 8.0.22 par centos8

Fabric. JS right click menu

OLED12864 液晶屏
![[golang syntax] be careful with the copy of slices](/img/5e/1c82c58940939b94d03377ebdc03e3.jpg)
[golang syntax] be careful with the copy of slices

Youth training camp -- database operation project

Fabric. JS compact JSON

Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash

Fabric. JS centered element
随机推荐
Fabric. JS background is not affected by viewport transformation
Importation de studio visuel
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
idea开发工具常用的插件合集汇总
文件包含漏洞(二)
Here comes a new chapter in the series of data conversion when exporting with easyexcel!
Fabric. JS iText sets the color and background color of the specified text
Fabric. JS activation input box
H5 jump applet
Usage record of vector
Oled12864 LCD screen
来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
3D printer G code command: complete list and tutorial
Visual Studio导入
小程序跳装到公众号
Visual studio import
Reflection of the soul of the frame (important knowledge)
Simply encapsulate JS and apply it
JVM class loading mechanism
Straighten elements (with transition animation)