use remainder to pick input
<p>im a bit stuck on this one so I thought id pass it on here.</p>

<p>I have a table which can be dynamicaly built with in put boxes for the y axis, x axis and for the value.</p>

<p>the name of the value input boxes are numbered from left to right, top to bottom.</p>

<pre><code>0,1
2,3
4,5
6,7
</code></pre>

<p>Lets say in the input box 7 i have entered a value and i want to get the X and y axis titles.</p>

<p>when the form is summbited by array is built.</p>

<pre><code>[heading_x] =&gt; Array
    (
        [0] =&gt; red
        [1] =&gt; black
    )

[heading_y] =&gt; Array
    (
        [0] =&gt; Small
        [1] =&gt; Medium
        [2] =&gt; Large
        [3] =&gt; X-Large
    )

[value] =&gt; Array
    (
        [1] =&gt; Array
            (
                [0] =&gt; 
                [1] =&gt; 
            )

        [2] =&gt; Array
            (
                [0] =&gt; 
                [1] =&gt; 
            )

        [3] =&gt; Array
            (
                [0] =&gt; 
                [1] =&gt; 
            )

        [4] =&gt; Array
            (
                [0] =&gt; 
                [1] =&gt; foo 
            )
</code></pre>

<p>The code i've wrote so far for finding the x and y axis out is as follows</p>

<pre><code>if( preg_match( "#^([0-9]+)\-value([0-9]+)\-([0-9]?)$#is", $key, $match ) ) {
                foreach( $attrDetails as $key_2 =&gt; $array ) {
                    if( $array['attribute_id'] == $match[1] &amp;&amp; $val != '0' &amp;&amp; $val != '' ) {
                        $options = unserialize( stripslashes( $attrDetails[$key_2]['attribute_options'] ) );
                        unset( $options['value'][0] ); 
                        print_r($options);
                        $max = count( $options['heading_x'] );
                        $base = $match[2] + 1;
                        $position_x = ( $base % $max ) + 1;
                        $position_y = ( ( floor( $base / $max ) - 1 ) &lt; 0 ? 0 : floor( $base / $max ) - 1 );
                        if( $match[3] == '' || $base == '0' ) {
                            if( $pd_details-&gt;pd_activate_special_offer == '1' &amp;&amp; $pd_details-&gt;pd_offer_price != '0.00' ) {
                                if( $array['attribute_type'] == '4' ) {
                                    $cost = $val * $pd_details-&gt;pd_offer_price;
                                }
                            }else{
                                if( $array['attribute_type'] == '4' ) {
                                    $cost = sprintf("%01.2f", $val * $pd_details-&gt;pd_price );
                                }   
                            }
                        }
                        die($position_x . ' / ' . $position_y);
                        echo $options['heading_y'][$position_y-1] . ' / ' . $options['heading_x'][$position_x-1] . " amount: $val cost: $cost &lt;br /&gt;\n"; 
                        $_SESSION['basket']['items']['top_option'][] = $options['heading_x'][$position_x-1];
                        $_SESSION['basket']['items']['side_option'][] = $options['heading_y'][$position_y-1];
                        $_SESSION['basket']['items']['amount'][] = $val;
                        $_SESSION['basket']['items']['price'][] = $cost;
                    }
                }
            }
</code></pre>

<p>the main bit being</p>

<pre><code>$max = count( $options['heading_x'] );
$base = $match[2] + 1;
$position_x = ( $base % $max ) + 1;
$position_y = ( ( floor( $base / $max ) - 1 ) &lt; 0 ? 0 : floor( $base / $max ) - 1 );
</code></pre>

<p>posiition y seems to be fine. My problem being lets say </p>

<blockquote>
  <p>floor( $base / $max ) - 1</p>
</blockquote>

<p>= 3.50.</p>

<p>I know that 3 is the third down (or key 3 i forgot) how can i use the remainder to find the x axis?</p>
