note 110295 added to function.strpos

From: Date: Mon, 08 Oct 2012 22:26:18 +0000
Subject: note 110295 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-191193@lists.php.net to get a copy of this message
Howto slice a string with strpos? The following example shows how to get a substring url from a string. <?php function pictureurl($string){ $first = strpos($string,"src="); $last = strpos($string,".jpg"); if(!is_numeric($last)){ $last = strpos($string,".JPG"); } if(!is_numeric($last)){ $last = strpos($string,".png"); } $url=""; for($i=$first+4;$i<=$last+4;$i++){ $url.=$string[$i]; } return $url; } ---- Server IP: 69.147.83.199 Probable Submitter: 89.133.82.252 ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- https://master.php.net/note/edit/110295 Del: integrated -- https://master.php.net/note/delete/110295/integrated Del: useless -- https://master.php.net/note/delete/110295/useless Del: bad code -- https://master.php.net/note/delete/110295/bad+code Del: spam -- https://master.php.net/note/delete/110295/spam Del: non-english -- https://master.php.net/note/delete/110295/non-english Del: in docs -- https://master.php.net/note/delete/110295/in+docs Del: other reasons-- https://master.php.net/note/delete/110295 Reject -- https://master.php.net/note/reject/110295 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191193) next »