Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除twitter文本标题中的最后一个标签_Php_Twitter - Fatal编程技术网

Php 删除twitter文本标题中的最后一个标签

Php 删除twitter文本标题中的最后一个标签,php,twitter,Php,Twitter,我想在我的公共帐户的已获取twitt中获取最后一个标记 这个物体看起来像 Array ( [0] => stdClass Object ( [created_at] => Tue Apr 25 16:04:57 +0000 2017 [id] => 856901856584454144 [id_str] => 856901856584454144 [text] => مق

我想在我的公共帐户的已获取twitt中获取最后一个标记

这个物体看起来像

    Array
    (
    [0] => stdClass Object
    (
        [created_at] => Tue Apr 25 16:04:57 +0000 2017
        [id] => 856901856584454144
        [id_str] => 856901856584454144
        [text] => مقتل مسؤول عن التفخيخ في فتح الشام بجرد #عرسال 
        `https://t . co/nLuASJDXgN` #لبنان `https://t . co /oMCgiTER0A`
        [truncated] => 
        [entities] => stdClass Object
            (
                [hashtags] => Array
                    (
                        [0] => stdClass Object
                            (
                                [text] => عرسال
                                [indices] => Array
                                    (
                                        [0] => 40
                                        [1] => 46
                                    )

                            )

                        [1] => stdClass Object
                            (
                                [text] => لبنان
                                [indices] => Array
                                    (
                                        [0] => 71
                                        [1] => 77
                                    )

                            )

                    )

                [symbols] => Array
                    (
                    )

我想从
text
属性中删除#hashtag,如果它位于
text
的末尾,并在一个变量中准备该字符串记住任何其他标签应保持原样。有人对此有想法吗?

也许可以尝试使用
strrpos()
来查找最后一次出现的#?是的,我们可以使用strpos($text,“#hashtag”,-nagative offset)从末尾开始,但有时文本结尾是URL您不需要负偏移量,请使用
strrpos
(注意额外的“r”)从最后开始搜索。通常你必须在它发生之前尝试一下。这是你想要的吗?