Regex is always better in this case but If your string pattern is fixed like ABCDEF123456GH, you can simply use substr like
$str = "ABCDEF432465GH";
echo substr($str, 6, -2);
Domanda
I got a simple php issue which is that I don't know how to use substring here...
ABCDEF[RAND NUMBER 1-10000000]GH
And so I need to get that random number using substring,
I dont know if my brain works correctly today but I really couldnt figure how to do that.
Soluzione
Regex is always better in this case but If your string pattern is fixed like ABCDEF123456GH, you can simply use substr like
$str = "ABCDEF432465GH";
echo substr($str, 6, -2);
Altri suggerimenti
This will do, no need for substr
or anything:
$string='ABCDEF432465GH';
echo preg_replace('/[a-z\[\] ]*/i', '', $string);
Regular expressions are better when you don't know where in the text is desired substring,
$string = "ABCDEF10000000GH";
if (preg_match("/(\d+)/", $string, $m)) {
print $m[1];
}