note 90849 added to function.preg-replace-callback

From: Date: Tue, 12 May 2009 20:17:58 +0000
Subject: note 90849 added to function.preg-replace-callback
Groups: php.notes 
Request: Send a blank email to php-notes+get-154525@lists.php.net to get a copy of this message
If you're planning to use preg_replace_callback inside a class, you need to use the array() function: class MyClass { function preg_callback_url($matches) { //var_dump($matches); $url = $matches[1].$matches[2]; $text = ''; $pos = strpos($url,' '); if ($pos!==FALSE) { $text = trim(substr($url,$pos+1)); $url = substr($url,0,$pos); } return '<a href="'.$url.'" rel="nofollow">'.(($text!='') ? $text : $url).'</a>'; } function ParseText($text) { return preg_replace_callback('/\[(http|https|ftp)(.*?)\]/iS',array( &$this, 'preg_callback_url'), $text); } } ---- Server IP: 69.147.83.197 Probable Submitter: 85.186.3.205 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace-callback.php Edit -- https://master.php.net/note/edit/90849 Del: integrated -- https://master.php.net/note/delete/90849/integrated Del: useless -- https://master.php.net/note/delete/90849/useless Del: bad code -- https://master.php.net/note/delete/90849/bad+code Del: spam -- https://master.php.net/note/delete/90849/spam Del: non-english -- https://master.php.net/note/delete/90849/non-english Del: in docs -- https://master.php.net/note/delete/90849/in+docs Del: other reasons-- https://master.php.net/note/delete/90849 Reject -- https://master.php.net/note/reject/90849 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154525) next »