How can I get the last 7 characters of a PHP string?

后端 未结 7 2046
太阳男子
太阳男子 2020-11-30 18:25

How would I go about grabbing the last 7 characters of the string below?

For example:

$dynamicstring = \"2490slkj409slk5409els\";
$newstring = some_f         


        
相关标签:
7条回答
  • 2020-11-30 19:09

    for last 7 characters

    $newstring = substr($dynamicstring, -7);
    

    $newstring : 5409els

    for first 7 characters

    $newstring = substr($dynamicstring, 0, 7);
    

    $newstring : 2490slk

    0 讨论(0)
提交回复
热议问题