Hi guys,
I have one multidim array and I have to unset the keys which are holding specific string(like "1235002") in its values and to write the new array into a text file.
Is it possible?
array->key->value("text text 1235002 text text")
array->key->value("text text 3123234 text text")
I have this so far:
$file = "text.txt";
$word1="HEAD";
$word2="FOOT";
$delimiter = 1111;
$handle = fopen($file, "r");
$contents = fread($handle, filesize($file));
fclose($handle);
$pattern = '/'.$word1.'(.*?)'.$word2.'/imsx';
preg_match_all($pattern,file_get_contents($file),$matches);
//echo "<pre>".print_r($matches,true).'</pre>';
//get the values of the multidim. array
$count = count ($matches);
for ($i=0; $i<$count; $i++){
$countmore=count($matches[$i]);
for ($j=0; $j < $countmore; $j++){
// print ($matches[$i][$j] . "<br> ");
$text =$matches[$i][$j]; // this should be a string
// echo $text ;
$tmp = explode(" ",$text) ;
$words = array();
foreach ($tmp as $v)
{
if (strlen($v)>0)
{
$words[] = $v;
}
}
$words_string = implode(' ',$words);
How should I proceed from this point?