I am using the explode function in php to split a string like "60-5000" into two elements that can be cast to integers.
$parts = explode('-', '60-5000',2);
$this->p1 = (integer)$parts[0];
$this->p2 = (integer)@$parts[1];
When this is ran in the constructor of my class I am getting this error:
Undefined offset: 1
When I suppress the error on the second element of the array I obtain the correct array
0 => "60"
1 => "5000"
Above is the debug statement with error suppressed on the second index.
I do not want to keep having to suppress this error to get the results from explode. Is there something wrong with my implementation?