如何使用 php 从 laravel 中的 json 数据分解以下值
How to explode the below value from json data in laravel using php
根据下面的数据,我需要显示 "Xeon E3 1230v3 Quad Core Server (21/09/2018 - 20/10/2018)" 以及如何展开剩余数据。
Xeon E3 1230v3 Quad Core Server (21/09/2018 - 20/10/2018) Server Addons - OS: CentOs Server Addons - Database: Mysql Server Addons - Controlpanel: Plesk
$chain = "Xeon E3 1230v3 Quad Core Server (21/09/2018 - 20/10/2018) Server Addons - OS: CentOs Server Addons - Database: Mysql Server Addons - Controlpanel: Plesk";
$regex = '/^([a-zA-Z0-9\-\s\(\/]*\))/';
$data['regex'] = $regex;
$data['chain'] = $chain;
if(preg_match( $regex, $chain, $matches)){
$remaining = str_replace($matches[0], "", $chain);
$parts = explode(':', $remaining);
$data['match'] = $matches[0];
for($i = 0; $i < count($parts); $i++){
$infos = explode('-', $parts[$i]);
$data['properties']["{$infos[0]}"] = $infos[1];
}
}
echo "<pre>";
print_r($data);
echo "</pre>";
根据下面的数据,我需要显示 "Xeon E3 1230v3 Quad Core Server (21/09/2018 - 20/10/2018)" 以及如何展开剩余数据。
Xeon E3 1230v3 Quad Core Server (21/09/2018 - 20/10/2018) Server Addons - OS: CentOs Server Addons - Database: Mysql Server Addons - Controlpanel: Plesk
$chain = "Xeon E3 1230v3 Quad Core Server (21/09/2018 - 20/10/2018) Server Addons - OS: CentOs Server Addons - Database: Mysql Server Addons - Controlpanel: Plesk";
$regex = '/^([a-zA-Z0-9\-\s\(\/]*\))/';
$data['regex'] = $regex;
$data['chain'] = $chain;
if(preg_match( $regex, $chain, $matches)){
$remaining = str_replace($matches[0], "", $chain);
$parts = explode(':', $remaining);
$data['match'] = $matches[0];
for($i = 0; $i < count($parts); $i++){
$infos = explode('-', $parts[$i]);
$data['properties']["{$infos[0]}"] = $infos[1];
}
}
echo "<pre>";
print_r($data);
echo "</pre>";