Chris, you can splice an array http://www.php.net/manual/sv/function.array-splice.php
Jan Grafstrom "Chris Winters" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > I'm having a bit of trouble... > > I have an array that consists of a string like this: > > string1\rstring2\rstring3\rstring4 > > I want to REMOVE STRING3, and keep the rest of the array intact - but cannot > figure on how to do it. I tried using functions such as preg_replace, strstr > and so forth... > > In my code this is how I go thru the array... > > //snippet... > > //search for carriage return, split it... > $line = preg_split( "/[\r]+/" ,$line); > reset($line); > > //Line will consists of array... > while (list ($key, $val) = each ($line)) > { > echo "<br>$key => $val"; > > if(strstr($val,$newmail)) > { > echo "<br>Found! and trying to delete....<br>"; > //What to do form this point, I have the slightest foggy... > } > } > > It finds it without ANY problems, but I cannot seem to "go" to the position > of found string, delete it, then keep the rest of the array. > I did manage to find this on php.net, but it doesnt seem to work: > function stri_replace2 ($search,$replace,$text) > { > if (!is_array($search)) > { > $search = array($search); > $replace = array($replace); > } > foreach($search AS $key => $val) > { > $search["$key"] = '/'.quotemeta($val).'/i'; > } > echo "$search $replace $text"; > > return preg_replace($search,$replace,$text); > } > > Could anyone help me with this? > > Thanks in advanced! > > Chris > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php