我有一个 php 变量,其中包含如下 url 字符串:
$url1 = 'http://test1.com/';
$url2 = 'https://test2.com';
$url3 = 'http://test3.com/';
Run Code Online (Sandbox Code Playgroud)
我想用特定字符串替换 http 或 https 前缀,并仅当字符串变量在字符串末尾包含破折号时删除末尾的破折号,例如:
$url1 = 'stackoverflow://test1.com';
$url2 = 'stackoverflow://test2.com';
$url3 = 'stackoverflow://test3.com';
Run Code Online (Sandbox Code Playgroud) 我有Y-m-d H:i:sUTC格式的日期时间字符串,我想将此字符串转换为Y-m-d H:i:sGMT + 7格式,例如:
$utcDateTime = '2018-10-02 04:08:17';
$gmtDateTime = $this->convertDateTime($utcDateTime);
echo $gmtDateTime; // 2018-10-02 11:01:02
Run Code Online (Sandbox Code Playgroud)