Just re-learned regular expressions since I haven't had to touch them in a while, and for some reason this isn't working, can anyone help me out?
The code is meant to get this: array(
"sub" => "<sub>",
"edit" => "<span style=\"font-size:8pt;\">"
);
and spit out another array like so: array(
"/sub" => "</sub>",
"/edit" => "</span>"
);
problem being, running this preg_replace on the values of the first array spits out whacked results: $newvalue = preg_replace('@<(\w)+\s*.*>.*@i','</${1}>',$value);
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
if you are trying to make UBB tags yourself that is, thats what I think, but Im doubting
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
Last edited by dmmh on Thu Sep 22, 2005 11:46 am, edited 1 time in total.
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
yes i'm doing BBcode, and yes that's similar, except i'd like to be able to have it possible to input it easily into the database, like:
'bbcode' => 'blink'
'code' => '<blink>'
btw, I developed a way to destroy people's session via my admin control panel. Kinda neat when you catch someone form re-submitting or suspect him of other bad stuff
user gets immediate notice (well, on new page or page refresh)
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
I'm no php expert (can one actually be an expert at a language that simple?) and I didn't have the time to figure out how to change the array keys as well.
The expression works on unbracketed keywords as well (so you can replace the keys in the array), so for example "img" will be replaced by "/img" and
I'm no php expert (can one actually be an expert at a language that simple?) and I didn't have the time to figure out how to change the array keys as well.
The expression works on unbracketed keywords as well (so you can replace the keys in the array), so for example "img" will be replaced by "/img" and
The reason for your strange output is the fact that you replaced the match with just one character from the original input (\w).
!! thank you so much phoq, and the reason behind it mucking up is clear to me now, thanks for helping me out.
And yes, PHP is quite a simple language but it gets the job done, and is easy to get straight from concept to working application, which is great when you have hardly any free time.