TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   assigning pcre replacements ( $1 or $2 or whatever ) to variables (http://www.talkphp.com/general/2671-assigning-pcre-replacements-1-2-whatever-variables.html)

Orc 04-21-2008 02:50 AM

assigning pcre replacements ( $1 or $2 or whatever ) to variables
 
I want to know how to do this. How do you take the replacements and assign them to variables?

delayedinsanity 04-21-2008 03:48 AM

I'm not sure if this is exactly what you were looking for, but I would do something like this, maybe;

PHP Code:

$szExplode preg_replace("/(first match)(second match)(so on)/""$1|$2|$3"$szString);
$aExplode explode("|"$szExplode); 

And now you have an array full of your matches. If I understood the question right?
-m

Orc 04-21-2008 04:15 AM

Quote:

Originally Posted by delayedinsanity (Post 13695)
I'm not sure if this is exactly what you were looking for, but I would do something like this, maybe;

PHP Code:

$szExplode preg_replace("/(first match)(second match)(so on)/""$1|$2|$3"$szString);
$aExplode explode("|"$szExplode); 

And now you have an array full of your matches. If I understood the question right?
-m

GAH, so simple a cave man can do it. >.< I'm sorry, but that was too simple, and I'm ranging myself to advanced, I guess I need to press harder into it. -_-

delayedinsanity 04-21-2008 04:51 AM

Sometimes you just have to step back and look at things from a different angle. I'm still really new at this stuff too, and some things that seem almost impossible to do one day, just jump out at me the next and I wonder how come I never saw it before.
-m

Orc 04-21-2008 04:53 AM

Quote:

Originally Posted by delayedinsanity (Post 13697)
Sometimes you just have to step back and look at things from a different angle. I'm still really new at this stuff too, and some things that seem almost impossible to do one day, just jump out at me the next and I wonder how come I never saw it before.
-m

I've been doing php for 1 and half years, so I guess I would be a little rusty sometimes, so oh well. I come from other languages, like C++, Java, and Shell. Thus I seem to quickly understand PHP.

Rendair 04-21-2008 08:55 AM

Quote:

Originally Posted by Orc (Post 13696)
GAH, so simple a cave man can do it. >.< I'm sorry, but that was too simple, and I'm ranging myself to advanced, I guess I need to press harder into it. -_-

I don't know if its me, but you can come across abit rude to some poeple when they give you their opinions and considering you did not say you wanted advance its hard for people to know lol.

Orc 04-21-2008 07:11 PM

Quote:

Originally Posted by Rendair (Post 13704)
I don't know if its me, but you can come across abit rude to some poeple when they give you their opinions and considering you did not say you wanted advance its hard for people to know lol.

Okay. (chars)

delayedinsanity 04-21-2008 07:53 PM

Quote:

I don't know if its me, but you can come across abit rude to some poeple when they give you their opinions and considering you did not say you wanted advance its hard for people to know lol.
I didn't get that at all. I read it like; *bangs head on table* I should've thought of that!

But I dunno, I never know. I've grown used to the fact that nobody can read your body language or hear your tone online and therefore a lot goes misinterpreted. I get accused of being an ass alllllll the time because I'm just very straightforward and have a sadisticly cynical and sarcastic sense of humor. Yes, I am working on making that into a tongue twister.

Anywho.
-m


All times are GMT. The time now is 01:32 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0