theme_preprocess_views_view_fields() function in drupal7 does not accept static variable as index This is my code

function THEME_preprocess_views_view_fields(&amp;$variables)
{
    static $i = 0;
    $variables['address'] = t($variables['view']-&gt;result[$i]-&gt;field_address[0]['raw']['uri']);
    $variables['address1'] = t($variables['view']-&gt;result[0]-&gt;field_address[0]['raw']['uri']);
    $i++;
}


I wrote the following code in views-view-fields-VIEWNAME--page.tpl.php :

&lt;?php print $address; ?&gt;
&lt;?php print $address1; ?&gt;


the second print successfully printed its relevant value but the first one displayed nothing. 

I tried to use this trick but i failed :

&lt;?php
if($i==0)
    $variables['address'] = t($variables['view']-&gt;result[0]-&gt;field_address[0]['raw']['uri'];
if($i==1)
    $variables['address'] = t($variables['view']-&gt;result[1]-&gt;field_address[0]['raw']['uri'];
.
.
.

?&gt;


why can't I use static variable as index?



UPDATE 

after useful comment of Clive and arpitr I modified my code and I created two THEME_preprocess_views_view_fields functions separately as follow: 

function THEME_preprocess_views_view_fields(&amp;$variables)
{
    static $i = 0;
    $view = $variables['view'];
    if($view-&gt;name == "MY_VIEW_NAME")
    {
    $variables['address'] = t($variables['view']-&gt;result[$i]-&gt;field_address[0]['raw']['uri']);
    $i++;
     }
}


and this one

function THEME_preprocess_views_view_fields(&amp;$variables)
{
    static $i = 0;
    $view = $variables['view'];
    if($view-&gt;name == "MY_VIEW_NAME")
    {
    $variables['address'] = t($variables['view']-&gt;result[$i]-&gt;field_address[0]['raw']['uri']);
     }
}


for the upper one it was the result

Array


and the second one (without $i++) successfully printed the right value.
Static vars aren't special beyond persisting inside the scope of the function they were created, for the duration of a single page build. You categorically can use a static var as an array index.

Take the following code:

function some_test(&amp;$variables) {
  static $i = 0;
  print $variables[$i];
  $i++;
}

$variables = array(
  0 =&gt; 'test1',
  1 =&gt; 'test2',
);

some_test($variables);
some_test($variables);


Which outputs the following:

test1
test2


Proving that $variables[$i] is accessed as expected.

The problem with you code must be somewhere else, as it's not being caused by a language issue as you suggest.

At a wild guess, $variables['view']-&gt;result isn't keyed in the same way you expect it to be (possibly keyed by the result's base table ID instead of a zero-based list). Dumping out $variables['view']-&gt;result should tell you pretty quickly what's happening.