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:
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);
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:
 => I_20_IH_21_23_HP_junio.
 => 20
 => 21_23
 => junio
Your value of I is in index 1, H in index2 and P in index 3