Jump to content

[SOLVED] preg_replace and vars problem?


archonik

Recommended Posts

A little backstory:

I store my 'items' in an array:

$a['ITEMNAME']['ITEMVALUE']

 

What I'm trying to do is build a piece of BBCode that will allow me to print the value of a provided 'item'... But trying to do so... Fails MISERABLY.

 

My code is (one of the X-ty versions I tried:)

 

$value = preg_replace("/[var](.+?)[/var]/", $a[$1]['itemvalue']', $output);

 

I tried many things... putting the $1 in {} etc. etc. but noting seems to work. Is there any way around that? The replace pattern works ok itself but it's the putting the thing inbetween and using it as a variable... complicates everything... Help, please?

Link to comment
https://forums.phpfreaks.com/topic/132271-solved-preg_replace-and-vars-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.