Text between tags

how to get the text between the tags <script type=“text/javascript” and </script>.

You can use either of the following examples

<script type="text/javascript">
// Single line comment

    Block comment

This what u mean?

$content = '<script type="text/javascript">
// some js
	// More some js
	// hulabaloo..

preg_match('/^<script type="text\\/javascript">(.*)<\\/script>$/s', $content, $result);


You could use DomDocument also.

$html = '
    <script type="text/javascript">

$dom = new DOMDocument;


Is there a reason(?) why you don’t just use shorter version…


There could be a script element in the head, so it would break. :wink:

&lt;annoy&gt;Maybe he wants to get scripts in the &lt;head&gt; too?..&lt;/annoy&gt; We’ll see when Santhana Lakshmi comes back. (: