<?php
$array = [-5, 1, 2, 3, 10, 11, 12, 13, 14, 23, 24, 25, 31];
for ($i = 1, $count = count($array); $i < $count; ++$i) { // deliberately re-count the array because array_splice() extends the array
if (($array[$i - 1] + 1) != $array[$i]) { // there is a gap between consecutive comparable values
array_splice($array, $i++, 0, 'xxx'); // inject new element in gap, then bump counter to avoid injected element
++$count;
}
}
var_export($array);