PHP get everything in a string before underscore

前端 未结 4 1855
既然无缘
既然无缘 2020-12-21 10:09

I have this code here:

$imagePreFix = substr($fileinfo[\'basename\'], strpos($fileinfo[\'basename\'], \"_\") +1);

this gets me everything after

4条回答
  •  鱼传尺愫
    2020-12-21 10:52

    If you want an old-school answer in the type of what you proposed you can still do the following:

    $imagePreFix = substr($fileinfo['basename'], 0, strpos($fileinfo['basename'], "_"));

提交回复
热议问题