Troubleshooting Analysis of String Loss Before Underscore When Deleting Other Characters at the Starting String Using Function ltrim in PHP 7.4
1. The value of the string: E:\wwwroot\object\storage\app/theme_dow nloads/2022/05/25/1653468314.0994.1295326141.zip
2. Values of other characters: E:\wwwroot\object\storage\app/
3. The code is implemented as follows
<?php
echo ltrim('E:\wwwroot\object\storage\app/theme_downloads/2022/05/25/1653468314.0994.1295326141.zip', 'E:\wwwroot\object\storage\app/');
?>
4. Results: _downloads/2022/05/25/1653468314.0994.1295326141.zip. Expected is: Theme_Downloads/2022/05/25/1653468314.0994.1295326141.zip. as shown in Figure 1
5. The code implementation is adjusted as follows, remove the last / of the values of other characters
<?php
echo ltrim('E:\wwwroot\object\storage\app/theme_downloads/2022/05/25/1653468314.0994.1295326141.zip', 'E:\wwwroot\object\storage\app');
?>
6. The results are in line with expectations: /theme_downloads/2022/05/25/1653468314.0994.1295326141.zip
7. Finally decided to use the function substr to achieve the same purpose. in line with expectations. as shown in Figure 2

