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

[eluser]amrnt[/eluser]
[quote author="Don Robin." date="1218223256"]Hi!
PHP function preg_replace seems to be something which I'll never completely understand, I suppose Smile
Here's the code:
Code:
$layout = preg_replace('~{(.+?)}~', '<div class="$1">'.$this->replace('$1').'</div>', $layout);
I have to replace everything which looks like this:
Code:
{some}
to this:
Code:
<div class="some"> stuff </div>
The problem appears because inside the div tag I have to print something which depends from what I have inside the brackets, but I can't pass the variable '$1' in my method $this->replace() becauase PHP sees it as just "$1".
Where's my mistake? Can't found it :-(
Thank you, in advance, guys. Smile[/quote]

remove the '' Wink from '$1' in replace('$1') ...
Code:
$layout = preg_replace('~{(.+?)}~', '<div class="$1">'.$this->replace($1).'</div>', $layout);


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