gpt4 book ai didi

php - 如何在 PHP 中获取字符串的最后一部分

转载 作者:可可西里 更新时间:2023-11-01 12:41:09 26 4
gpt4 key购买 nike

我有许多遵循相同约定的字符串:

this.is.a.sample
this.is.another.sample.of.it
this.too

我想做的是隔离最后一部分。所以我想要“示例”或“它”或“太”。

实现这一目标的最有效方法是什么。显然有很多方法可以做到这一点,但哪种方法使用最少的资源(CPU 和 RAM)是最好的。

最佳答案

$string = "this.is.another.sample.of.it";
$contents = explode('.', $string);

echo end($contents); // displays 'it'

关于php - 如何在 PHP 中获取字符串的最后一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9765351/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com