Search an array?
I need to get data from an input form into an array. I got all the information input, but now I need to be able to search it....this is what I have.
FORM PAGE:
<HTML><HEAD><TITLE></TITLE></HEAD><BODY><form name="stateentry" method=post action=states.php>
<input type="text" name="states2">
<input type="text" name="states3">
<input type="text" name="states4">
<input type="text" name="states5">
<input type="text" name="states6">
<input type="hidden" name="states0" value="">
<input type="hidden" name="states1" value="">
<input type="reset">
<input type="submit">
</form>
</BODY></HTML>
PHP PAGE
<?php
$states[0] = $HTTP_POST_VARS["states0"];
$states[1] = $HTTP_POST_VARS["states1"];
$states[2] = $HTTP_POST_VARS["states2"];
$states[3] = $HTTP_POST_VARS["states3"];
$states[4] = $HTTP_POST_VARS["states4"];
$states[5] = $HTTP_POST_VARS["states5"];
$states[6] = $HTTP_POST_VARS["states6"];
?>
I have added an echo statement to the end so I know all the values are being added. My question is, I have to search the array for a word that ends in xas, and move it to element 0 in the array.
I am sort of confused on how to search them. I was thinking a regular expression maybe?
if(ereg('xas', $state, $xas){
$states[0] = $xas
}
But if you search a string and it matches, then it only returns true. How can I search the string, and if there is a match, isolate that array element and move it to a different element (say from 5 to 0)?
I am very confused on this, regular expressions are above me, heh.