在PHP中选择数组元素

So I have the following array:

$ISBN = '0,1,9,8,5,x,8,0,3,0';

$inArray = explode(',',$ISBN);

While this loop prints the numbers 10-1 like so 10 9 8 7 6 5 4 3 2 1:

for($i=10; $i>0; $i=$i-1)
{
    echo $i." ";
}

I want to multiply each element accordingly starting from the first one. For example: 10*inArray[0] + 9*inArray[1] + 8*inArray[2] and when it hits x to print it like 6*x for example; etc.

Something like this:

$factor = count($inArray);
foreach($inArray as &$value) {
    if($value != "x") {
       $value *= $factor;
    } else {
       $value = $factor.'*'.$value; 
    }
    $factor--;
}
unset($value);

Value of $inArray would be:

0,9,72,56,30,5*x,32,0,6,0