I select from the site base all short news ( short_story ) through the cycle, while it is necessary to leave only the text and remove the images. For this I use a regular expression. Sample code below. Regular expression works. Help to understand the newcomer.

 $i=0; while($row = mysql_fetch_array($query)) { $autor[$i]=$row['autor']; echo "Автор: ".$autor[$i]."<br>\n"; $short_story[$i]=$row['short_story']; preg_match("!([А-Яа-я 0-9\-_!,.:#\\$+=?)(])*!si",$short_story[$i],$short_story[$i]); echo "Короткая новость: {$short_story[$i][1]}<br>\n"; $alt_name[$i]=$row['alt_name']; echo "Папка: ".$alt_name[$i]."<br>\n"; $date[$i]=explode(' ',$row['date']); echo "Дата: ".$date[$i][0]."<br>\n"; echo "<hr>"; $i++; } 

Here is what is stored in the database in the short_story field:

 Сын накопил небольшую сумму денег к новому году, попросил купить продуктов, помочь сделать сендвичи и раздать бездомным в нашем городе.<br /> <p style=\"text-align:center;\"><img src=\"/uploads/posts/2014-12/1419680862_1.jpg\" /></p> <p>&nbsp;</p><br /> 
  • What causes the difficulty? Just want to figure out how a regular expression works? Or something does not suit the work of the script? - cheops
  • This script does not work. An empty array comes to $ short_story [$ i] [1]. - Vadim
  • An example of the text from the base can you give? - Naumov

0