Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用preg#u replace替换某些阵列(第一行不起作用)_Php_Arrays_Preg Replace - Fatal编程技术网

Php 用preg#u replace替换某些阵列(第一行不起作用)

Php 用preg#u replace替换某些阵列(第一行不起作用),php,arrays,preg-replace,Php,Arrays,Preg Replace,我正在编写一些代码,您可以上传一个txt文件,并在数组中读取它。现在我想用preg_replace更改这个数组的一些行,但是第一个数组不会更改 这是密码 HTML: 向你问好,史蒂文你的问题在这里: $array_liste = array(); 将其更改为: 您的代码中没有preg_替换。请您将问题简化一点好吗?输入的详细信息、您期望的输出以及它的真实情况。不管是str_replace还是preg_replace。我的代码中也有同样的错误。这是一张图像,数组1中的东西是一个小点。有人能说出这

我正在编写一些代码,您可以上传一个txt文件,并在数组中读取它。现在我想用preg_replace更改这个数组的一些行,但是第一个数组不会更改

这是密码

HTML:

向你问好,史蒂文你的问题在这里:

$array_liste = array();
将其更改为:


您的代码中没有preg_替换。请您将问题简化一点好吗?输入的详细信息、您期望的输出以及它的真实情况。不管是str_replace还是preg_replace。我的代码中也有同样的错误。这是一张图像,数组1中的东西是一个小点。有人能说出这是什么吗?谢谢你的帮助
<?php
$geladene_seite = $_FILES['my_text']['tmp_name'][0];
$array_liste = array(0);
$my_text_file = file($geladene_seite);

foreach ($my_text_file as $single_file) {
  $single_file = trim($single_file);    //  leerzeichen entfernen
  if (strlen($single_file) > 0){
    $single_file = str_replace(chr(10), '', $single_file);
    $single_file = str_replace(chr(13), '', $single_file);
    $menge = array_push ($array_liste, $single_file);
  }
}

echo '<hr><pre>';
print_r ($array_liste);
echo '</pre>';

$text1 = str_replace($array_liste[1], '<b>'.$array_liste[1].'</b>', $array_liste[10]);
$text2 = str_replace($array_liste[2], '<b>'.$array_liste[2].'</b>', $array_liste[11]);
$text3 = str_replace($array_liste[3], '<b>'.$array_liste[3].'</b>', $array_liste[12]);

echo '<p>'.$text1.'</p>';
echo '<p>'.$text2.'</p>';
echo '<p>'.$text3.'</p>';

?>
text one
text two
text three

this is for description one
this is for description two
this is for description three

header for number one
header for number two
header for number three

many more infos for the text one many more infos for the text one many more infos for the text one many more infos for the text one many more infos for the text one many more infos for the text one
many more infos for the text two many more infos for the text two many more infos for the text two many more infos for the text two many more infos for the text two many more infos for the text two
many more infos for the text three many more infos for the text three many more infos for the text three many more infos for the text three many more infos for the text three many more infos for the text three
$array_liste = array(0);
$array_liste = array();