Welcome Guest, Not a member yet? Register   Sign In
preg replace (again -.-)
#9

[eluser]Young Caveman[/eluser]
[quote author="inparo" date="1218225361"]Use preg_replace_callback if you need to process one of the captured strings.
Code:
$layout = preg_replace_callback('~{(.+?)}~', array($this, 'replace_function'), $layout);

function replace_function($matches)
{
    $match = $matches[1]; // 0 is the whole thing, 1 is the first subpattern
    
    // Do something with $match

    return '<div class="'.$matches[1].'">'.$match.'</div>';
}
[/quote]

Oh, Wow. :|
This works great. Smile Really, thank you inparo. Smile


Messages In This Thread
preg replace (again -.-) - by El Forum - 08-08-2008, 08:20 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:24 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:26 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:27 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:28 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:37 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:38 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 08:56 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 09:01 AM
preg replace (again -.-) - by El Forum - 08-08-2008, 09:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB