As stated in the comments use the function substr() to return a part of a string.
This function has the following signature:
substr ( string $string , int $start [, int $length ] ) : string
Where:
$string: It is the string whose part must be returned.
$start : It is the index where the substring part begins to be returned.
$length: It is the length of substring to be returned.
In the manual of substr() there are other important considerations regarding the parameters $start and $length.
Example:
<?php
$s = "95YAH0T01MJ456348";
//O primeiro elemento, onde o índice é zero, são os seis primeiros caracteres de $s
//o segundo elemento, cujo índice é um, são os caracteres remanescentes.
$res = [substr($s, 0, 6), substr($s, 6)];
print_r($res);
?>
Resulting:
Array
(
[0] => 95YAH0
[1] => T01MJ456348
)
https://www.php.net/manual/en/function.substr.php
– hkotsubo
I got it with your comment, super simple, thank you!
– Leandro Ramos
Just to be clear: your string (95YAH0T01MJ456348) contains 17 characters but only 11 digits. Maybe you are confusing the nomenclature. If it can contain a mixture of characters and you want to consider only 6 digits the position where separate can vary. Define clearly and precisely your problem.
– anonimo