Okay, to copy this over from our chat, I believe this is the solution:
<?php
$set1 = explode(",", '1,0,1');
$set2 = explode(",", '1,1,0');
$allbetween = _allbetween($set1, $set2);
echo 'All Between: '.$allbetween.'<br/>';
$allcount = count(explode("|", $allbetween))-1;
echo 'Number Of Blocks: '.$allcount;
function _allbetween($coords1, $coords2) {
$blocks = "";
for ($i=0; $i<=2; $i++) {
if ($coords1[$i] > $coords2[$i]) {
$tmp = $coords1[$i];
$coords1[$i] = $coords2[$i];
$coords2[$i] = $tmp;
}
}
for ($i1=$coords1[0]; $i1<=$coords2[0]; $i1++)
{
for ($i2=$coords1[1]; $i2<=$coords2[1]; $i2++)
{
for ($i3=$coords1[2]; $i3<=$coords2[2]; $i3++)
{
$blocks.= $i1.",".$i2.",".$i3."|";
}
}
}
return $blocks;
}
?>
The reason this works is that there is a swap loop at the beginning of your function, which swaps any of the three sets of values if the first is greater than the second. This ensures that all values "between" them can be calculated.
Edit: Fixing the demo link to the correct URL