In your case, I would use patterns with preg_match. I give you the example of the pattern of your case (from what I have understood, the values of what you want to get are between I_ and I, H and H and P y. Then your employer could be:
/I_(.*)_IH_(.*)_HP_(.*)\./
with preg_match you indicate the pattern, the string and the array where to save the results.
$nombre = "I_20_IH_21_23_HP_junio.jpg";
$patron = "/I_(.*)_IH_(.*)_HP_(.*)\./";
$result = preg_match($patron, $nombre, $resultados);
print_r($resultados);
In the example, you could draw an array with four elements, the first is the whole chain, and the others are each of the substrings you are looking for.
In result you would have an array like the following:
Array
(
[0] => I_20_IH_21_23_HP_junio.
[1] => 20
[2] => 21_23
[3] => junio
)
Your value of I is in index 1, H in index2 and P in index 3