Thanks for the new strategy :-)
I tested this out and couldn't figure out how to get the array returned I want.
The array_diff is returning the removed chairs, not the chairs leftover?
I tried to return the $arr[$index] as you suggested but that doesn't return any value.
I have enclosed the output. Probably what I want is array_diff($arr[$index],??)
thanks again.
<?PHP
function count_chairs($arr)
{
// how many elements in array
$i = count($arr);
// Create an index to positions 0, 2, 4, ... $i
$index = range(0, $i, 2);
echo "<pre>" ."INDEX" ." ";
print_r($index);
echo "</pre>";
return array_diff($arr,$index);
// Return the data at positions 0, 1, 2, ...
// return $arr[$index]; ***********
}
//fill array
$arychairs= range(1,100);
$filtered = count_chairs($arychairs);
echo "<pre>";
echo "filtered". print_r($filtered);
echo "</pre>";
echo "<pre>";
echo "Removed". print_r($filtered);
echo "</pre>";
?>
INDEX Array
(
[0] => 0
[1] => 2
[2] => 4
[3] => 6
[4] => 8
[5] => 10
[6] => 12
[7] => 14
[8] => 16
[9] => 18
[10] => 20
[11] => 22
[12] => 24
[13] => 26
[14] => 28
[15] => 30
[16] => 32
[17] => 34
[18] => 36
[19] => 38
[20] => 40
[21] => 42
[22] => 44
[23] => 46
[24] => 48
[25] => 50
[26] => 52
[27] => 54
[28] => 56
[29] => 58
[30] => 60
[31] => 62
[32] => 64
[33] => 66
[34] => 68
[35] => 70
[36] => 72
[37] => 74
[38] => 76
[39] => 78
[40] => 80
[41] => 82
[42] => 84
[43] => 86
[44] => 88
[45] => 90
[46] => 92
[47] => 94
[48] => 96
[49] => 98
[50] => 100
)
Array
(
[0] => 1
[2] => 3
[4] => 5
[6] => 7
[8] => 9
[10] => 11
[12] => 13
[14] => 15
[16] => 17
[18] => 19
[20] => 21
[22] => 23
[24] => 25
[26] => 27
[28] => 29
[30] => 31
[32] => 33
[34] => 35
[36] => 37
[38] => 39
[40] => 41
[42] => 43
[44] => 45
[46] => 47
[48] => 49
[50] => 51
[52] => 53
[54] => 55
[56] => 57
[58] => 59
[60] => 61
[62] => 63
[64] => 65
[66] => 67
[68] => 69
[70] => 71
[72] => 73
[74] => 75
[76] => 77
[78] => 79
[80] => 81
[82] => 83
[84] => 85
[86] => 87
[88] => 89
[90] => 91
[92] => 93
[94] => 95
[96] => 97
[98] => 99
)
filtered1
Array
(
[0] => 1
[2] => 3
[4] => 5
[6] => 7
[8] => 9
[10] => 11
[12] => 13
[14] => 15
[16] => 17
[18] => 19
[20] => 21
[22] => 23
[24] => 25
[26] => 27
[28] => 29
[30] => 31
[32] => 33
[34] => 35
[36] => 37
[38] => 39
[40] => 41
[42] => 43
[44] => 45
[46] => 47
[48] => 49
[50] => 51
[52] => 53
[54] => 55
[56] => 57
[58] => 59
[60] => 61
[62] => 63
[64] => 65
[66] => 67
[68] => 69
[70] => 71
[72] => 73
[74] => 75
[76] => 77
[78] => 79
[80] => 81
[82] => 83
[84] => 85
[86] => 87
[88] => 89
[90] => 91
[92] => 93
[94] => 95
[96] => 97
[98] => 99
)
Removed1