<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PHP - הסרת תגית style]]></title><description><![CDATA[<p dir="auto">אני רוצה להמיר HTML לטקסט.<br />
כמובן שיש פונקציה פשוטה <code>()strip_tags</code>, אך כידוע, זה לא מסיר את הstyle כי זה בין התגיות.</p>
<p dir="auto">כתבתי משהו כזה:</p>
<pre><code>function html2txt($text) {
	$text = strip_tags($text, "&lt;style&gt;"); 
	$substring = substr($text,strpos($text,"&lt;style"),strpos($text,"&lt;/style&gt;")+2);
	$text = str_replace($substring,"",$text);
	$text = str_replace("&amp;rsquo;","'", $text); 
	$content = preg_replace("/&amp;#?[a-z0-9]{2,8};/i","",$text );
	return $content;
}
</code></pre>
<p dir="auto">רק שהבעיה שזה מסיר רק את המופע הראשון של הstyle, אם יש כמה מופעים.</p>
<p dir="auto">מהי הדרך הפשוטה לכתוב את זה?</p>
]]></description><link>https://tchumim.com/topic/3815/php-הסרת-תגית-style</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Mar 2026 16:50:52 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/3815.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Nov 2018 20:42:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PHP - הסרת תגית style on Thu, 08 Nov 2018 11:09:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a> למעשה השתמשתי ברגולורי, בינתיים זה עובד טוב, פרויקט קטנטן וחובבני...</p>
<pre><code>function html2txt($text) {
	$text = preg_replace('/(&lt;(script|style)\b[^&gt;]*&gt;).*?(&lt;\/\2&gt;)/is', "", $text);
	$text = strip_tags($text, "&lt;style&gt;");
	$text = str_replace("&amp;rsquo;","'", $text); 
	$content = preg_replace("/&amp;#?[a-z0-9]{2,8};/i","",$text );
	$content = join("\n", array_map("ltrim", explode("\n", $content)));
	$content = preg_replace('/[\r\n]{4,9999}/', "\n", $content);
	return $content;
}

</code></pre>
]]></description><link>https://tchumim.com/post/38906</link><guid isPermaLink="true">https://tchumim.com/post/38906</guid><dc:creator><![CDATA[WWW]]></dc:creator><pubDate>Thu, 08 Nov 2018 11:09:11 GMT</pubDate></item><item><title><![CDATA[Reply to PHP - הסרת תגית style on Thu, 08 Nov 2018 05:06:39 GMT]]></title><description><![CDATA[<p dir="auto">עדיף DOM. גם בגלל שכל מנוע ייעודי טוב מרגקס, ובמיוחד במקרה הזה שREGEX עלול לעשות צרות (זמן ותוצאות לא צפויים) אם הקלט יהיה בעייתי.</p>
]]></description><link>https://tchumim.com/post/38894</link><guid isPermaLink="true">https://tchumim.com/post/38894</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Thu, 08 Nov 2018 05:06:39 GMT</pubDate></item><item><title><![CDATA[Reply to PHP - הסרת תגית style on Wed, 07 Nov 2018 20:52:06 GMT]]></title><description><![CDATA[<p dir="auto">מצאתי פה משהו:<br />
<a href="https://stackoverflow.com/questions/20082476/remove-everything-within-script-and-style-tags" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/20082476/remove-everything-within-script-and-style-tags</a></p>
<p dir="auto">מה עדיף DOM או regex?<br />
השני נראה יותר קל, השאלה אם אין לו חריגות.</p>
]]></description><link>https://tchumim.com/post/38875</link><guid isPermaLink="true">https://tchumim.com/post/38875</guid><dc:creator><![CDATA[WWW]]></dc:creator><pubDate>Wed, 07 Nov 2018 20:52:06 GMT</pubDate></item></channel></rss>