note 68936 added to function.substr

From: Date: Wed, 16 Aug 2006 16:31:18 +0000
Subject: note 68936 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-115977@lists.php.net to get a copy of this message
<?php //function to get a substring between between two other substrings function substring_between($haystack,$start,$end) { if (strpos($haystack,$start) === false || strpos($haystack,$end) === false) { return false; } else { $start_position = strpos($haystack,$start)+strlen($start); $end_position = strpos($haystack,$end); return substr($haystack,$start_position,$end_position-$start_position); } } //use of this function to get the title of an html document $handle = fopen($filename, 'r'); $contents = fread($handle, filesize($filename)); fclose($handle); $contents = htmlspecialchars($contents); $title = substring_between($contents,'&lt;title&gt;','&lt;/title&gt;'); ?> ---- Server IP: 216.194.113.175 Probable Submitter: 70.22.37.231 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/68936 Del: integrated -- https://master.php.net/note/delete/68936/integrated Del: useless -- https://master.php.net/note/delete/68936/useless Del: bad code -- https://master.php.net/note/delete/68936/bad+code Del: spam -- https://master.php.net/note/delete/68936/spam Del: non-english -- https://master.php.net/note/delete/68936/non-english Del: in docs -- https://master.php.net/note/delete/68936/in+docs Del: other reasons-- https://master.php.net/note/delete/68936 Reject -- https://master.php.net/note/reject/68936 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115977) next »