<?php
$MsgAry1 = ["A","B","C","D","E","F","G","H","I","J",
"K","L","M","N","O","P","Q","R","S","T",
"U","V","W","X","Y","Z","a","b","c","d",
"e","f","g","h","i","j","k","l","m","n",
"o","p","q","r","s","t","u","v","w","x",
"y","z","1","2","3","4","5","6","7","8",
"9","0",".",",","'","?","!"," ","_","-"];
$strings = [
'test',
'1234',
'w0ws3r!',
'##tag##',
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'?! _-"
];
foreach ($strings as $string) {
echo "$string match: " . var_export(!preg_match('~[^\w.,\'?! -]~', $string), true) . "\n";
echo "$string ltrim: " . var_export(!strlen(ltrim($string, implode($MsgAry1))), true) . "\n";
echo "$string ranged ltrim, chars remaining: \"" . ltrim($string, 'A..Za..z0..9.,\'?! _-') . "\"\n---\n";
}
- Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- test match: true
test ltrim: true
test ranged ltrim, chars remaining: ""
---
1234 match: true
1234 ltrim: true
1234 ranged ltrim, chars remaining: ""
---
w0ws3r! match: true
w0ws3r! ltrim: true
w0ws3r! ranged ltrim, chars remaining: ""
---
##tag## match: false
##tag## ltrim: false
##tag## ranged ltrim, chars remaining: "##tag##"
---
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'?! _- match: true
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'?! _- ltrim: true
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'?! _- ranged ltrim, chars remaining: ""
---
preferences:
125.49 ms | 403 KiB | 117 Q