$test = explode("\n", stripslashes($_POST['meta'])); $meta = get_meta_tags($file); foreach ($meta as $value => $key) { $replace = preg_grep('/]*'.$value.'[^>]*content="([^>]+)"[^>]*>|Ui/', $test); $pattern = '/]*'.$value.'[^>]*content="([^>]+)"[^>]*>|Ui/'; $html = preg_replace($pattern, $replace[0], $html); //$replaceKey = array_search($metaTag, $test); }