Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-17-2020, 05:39 AM   #1
Mr Pheer
Living inside your head.
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: In your AirBNB
Posts: 20,468
Some PHP help, please?

So I have this array like this

Code:
[location] => 2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149
What I want to do, is make it into three separate variables, like this

Code:
$city = 'Las Vegas';
$region = 'Nevada';
$zipcode = '89149';
How do I do that?
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:04 AM   #2
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by Mr Pheer View Post
So I have this array like this

Code:
[location] => 2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149
What I want to do, is make it into three separate variables, like this

Code:
$city = 'Las Vegas';
$region = 'Nevada';
$zipcode = '89149';
How do I do that?

Hey, I just woke up so can't write the code but I just go through and parse it out based on the words.

something along the lines of:

$location='2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149';

$location=strtolower($location);
$city=substr($location,strpos($location,'city')+4) ;
$city=substr($city,0,strpos($city,'region');

$region=substr($location,strpos($location,'region' )+6);
$region=substr($region,0,strpos($region,'region');

$zip=substr($location,strpos($location,'zip code')+8);


There is probably a more elegant way but like I said, I just woke up ;p
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:08 AM   #3
Mr Pheer
Living inside your head.
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: In your AirBNB
Posts: 20,468
Quote:
Originally Posted by sarettah View Post
Hey, I just woke up so can't write the code but I just go through and parse it out based on the words.
I'm only up because I was coding shit and didn't sleep last night

Thanks for the help. What is the +4, +6, and +8 for?
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:09 AM   #4
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
$location="2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149";

$replace= array("City: ","Region: ","Zip Code: ");
$location = str_replace($replace,"",$location);
$arr = explode("\n",$location);
$city = trim($arr[1]);
$region = trim($arr[2]);
$zipcode = trim($arr[3]);
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:12 AM   #5
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Quote:
Originally Posted by Mr Pheer View Post
I'm only up because I was coding shit and didn't sleep last night

Thanks for the help. What is the +4, +6, and +8 for?
It's to offset the number of characters but it's wrong, because he didn't factor in the : and the space after it. He also left out two )'s
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:18 AM   #6
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Another way if the order isn't identical each time.

<?php
$location="2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149";

$location = explode("\n",$location);
unset($location[0]);
foreach($location as $i) {
$out = explode(":",$i);
$dataOut[trim($out[0])] = trim($out[1]);
}
print_r($dataOut);

Array ( [City] => Las Vegas [Region] => Nevada [Zip Code] => 89149 )
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:20 AM   #7
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by k0nr4d View Post
It's to offset the number of characters but it's wrong, because he didn't factor in the : and the space after it. He also left out two )'s
You do it before coffee damnit.

However if you are doing an array it is probably more like this:

$location=array('2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149',
'2020-10-16 04:08PM -0700
City: Las Vegas2
Region: Nevada2
Zip Code: 89150',
'2020-10-16 04:08PM -0700
City: Las Vegas3
Region: Nevada3
Zip Code: 89151',
'2020-10-16 04:08PM -0700
City: Las Vegas4
Region: Nevada4
Zip Code: 89152');

$newlocation=array();
foreach($location as $loc)
{
$city=substr($loc,strpos($loc,'city')+5);
$newlocation[]['city']=substr($city,0,strpos($city,'region'));

$region=substr($loc,strpos($loc,'region')+7);
$newlocation[]['region']=substr($region,0,strpos($region,'region'));

$newlocation[]['zip code']=substr($loc,strpos($loc,'zip code')+9);
}

var_dump($newlocation);


-------------------------

And that one doesn't leave off the )'s and it assumes that the order of the vars is the same.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:32 AM   #8
Mr Pheer
Living inside your head.
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: In your AirBNB
Posts: 20,468
Thanks guys, I've got enough here to get it done now
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 05:47 PM   #9
CaptainHowdy
Too lazy to set a custom title
 
CaptainHowdy's Avatar
 
Industry Role:
Join Date: Dec 2004
Location: Happy in the dark.
Posts: 92,999
Quote:
Originally Posted by sarettah View Post
You do it before coffee damnit.
__________________
FLASH SALE INSANITY! deal with a 100% Trusted Seller
Buy Traffic Spots on a High-Quality Network

1 Year or Lifetime — That’s Right, Until the Internet Explodes!
CaptainHowdy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 06:56 PM   #10
ruff
I have a plan B
 
ruff's Avatar
 
Industry Role:
Join Date: Aug 2004
Location: Seattle - Miami - St Kitts
Posts: 5,501
I wouldn't try anything before coffee.
__________________
CryptoFeeds
ruff is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 07:12 PM   #11
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
There's a java joke in here somewhere..
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 08:00 PM   #12
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,038
Quote:
Originally Posted by Colmike7 View Post
There's a java joke in here somewhere..
Don't Java before Java? - I know it's PHP but it's the best I could do - I haven't had any coffee yet...
__________________
-

Chaturbate Script - https://gfy.com/fucking-around-and-b...er-issues.html - Now supports White Labels
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 08:09 PM   #13
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Just wait till i'm in charge around here. You are all going to regret making fun of me.


Dammit.

.
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 08:31 PM   #14
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,038
Quote:
Originally Posted by sarettah View Post
Just wait till i'm in charge around here. You are all going to regret making fun of me.


Dammit.

.
Sorry - ...

I love you even though you can't count to 6.....

If you get stuck again it's the number of fingers you have on your left hand...









.

Sorry again, I'm in one of those moods.....
__________________
-

Chaturbate Script - https://gfy.com/fucking-around-and-b...er-issues.html - Now supports White Labels
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 09:10 PM   #15
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by EddyTheDog View Post
Sorry - ...

I love you even though you can't count to 6.....

If you get stuck again it's the number of fingers you have on your left hand...

Sorry again, I'm in one of those moods.....
They did not require any math for a programming degree (believe it or not)

I debugged it and found the issues before K0nr4d said anything dammit.

Fuckers picking on me.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 09:21 PM   #16
Spunky
I need a beer
 
Spunky's Avatar
 
Industry Role:
Join Date: Jun 2002
Location: ♠ Toiletville ♠
Posts: 133,919
Ballers hire people to do that
__________________
Spunky is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 09:37 PM   #17
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,038
Quote:
Originally Posted by Spunky View Post
Ballers hire people to do that
I disagree - Real BALLERS come to GFY and ask - That's why they are BALLERS - You could pay a grand for that info, a grand you can invest - Maybe if you are millions in you can waste money like that...

Lets see - I could pay a grand for some company to come back to me a week later - Or post on GFY and get the answer within a few hours - A few years ago it would have been minutes.....

I was going to do a Trump joke - I would get told off though...
__________________
-

Chaturbate Script - https://gfy.com/fucking-around-and-b...er-issues.html - Now supports White Labels
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 09:41 PM   #18
Spunky
I need a beer
 
Spunky's Avatar
 
Industry Role:
Join Date: Jun 2002
Location: ♠ Toiletville ♠
Posts: 133,919
Quote:
Originally Posted by EddyTheDog View Post
I disagree - Real BALLERS come to GFY and ask - That's why they are BALLERS - You could pay a grand for that info, a grand you can invest - Maybe if you are millions in you can waste money like that...

Lets see - I could pay a grand for some company to come back to me a week later - Or post on GFY and get the answer within a few hours - A few years ago it would have been minutes.....

I was going to do a Trump joke - I would get told off though...
Mr Pheer wipes his ass with dolla bills
__________________
Spunky is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 10:12 PM   #19
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,038
Quote:
Originally Posted by Spunky View Post
Mr Pheer wipes his ass with dolla bills
I wipe my ass with your 2 cents...

Sorry Mr Pheer - Totally derailed your thread.....

Spunky - You apolligise as well...
__________________
-

Chaturbate Script - https://gfy.com/fucking-around-and-b...er-issues.html - Now supports White Labels
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 10:51 PM   #20
shake
frc
 
Industry Role:
Join Date: Jul 2003
Location: Bitcoin wallet
Posts: 4,664
this reminds my why i switched to nodejs from php, makes this like this much simpler
__________________
Crazy fast VPS for $10 a month. Try with $20 free credit
shake is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 11:40 PM   #21
Mr Pheer
Living inside your head.
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: In your AirBNB
Posts: 20,468
Quote:
Originally Posted by shake View Post
this reminds my why i switched to nodejs from php, makes this like this much simpler
Yeah and I switched to Python as was blown away by it's simplicity. But sometimes shit just has to be done in PHP and I can't remember much of it because I hardly ever write it anymore.
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2020, 11:45 PM   #22
Mr Pheer
Living inside your head.
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: In your AirBNB
Posts: 20,468
Quote:
Originally Posted by sarettah View Post
They did not require any math for a programming degree (believe it or not)

I debugged it and found the issues before K0nr4d said anything dammit.

Fuckers picking on me.

.
Really? No math?

My kid is in for his Bachelor's in Computer Science at UNLV and they have him in Calculus 2 and I'm like, wtf you need that for?

They also don't teach him anything except for C programming. When I ask him for PHP help he tells me "that's web shit, dude"
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 12:00 AM   #23
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by Mr Pheer View Post
Really? No math?

My kid is in for his Bachelor's in Computer Science at UNLV and they have him in Calculus 2 and I'm like, wtf you need that for?

They also don't teach him anything except for C programming. When I ask him for PHP help he tells me "that's web shit, dude"
Yeah, I did not do computer science. I probably should have.

Lol at the C attitude. A friend of mine has a kid who is self taught C but unemployed. I told him I could throw him some PHP work and he was like "I only do C". My reply was "How much you makking doing that?". He didn't like that.

Not putting down C programmers at all there. I program in C when I have to. I also do some python, hell I still do foxpro, cobol, VB, whatever language is needed.

However, if you want to work for yourself, the easiest work to find is PHP because so much of the web stuff is written in PHP, that simple, ya know?

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 12:40 AM   #24
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
No one ever said PHP was a good programming language...

k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 01:06 AM   #25
EddyTheDog
Just Doing My Own Thing
 
EddyTheDog's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: London, Spain, New Zealand, GFY - Not Croydon...
Posts: 25,038
Quote:
Originally Posted by k0nr4d View Post
No one ever said PHP was a good programming language...

From you that's fucking hilarious!..
__________________
-

Chaturbate Script - https://gfy.com/fucking-around-and-b...er-issues.html - Now supports White Labels
EddyTheDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 03:40 AM   #26
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
Looks like json, maybe you should ask for all the data.
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 11:29 AM   #27
baddog
So Fucking Banned
 
Industry Role:
Join Date: Apr 2001
Location: the beach, SoCal
Posts: 107,090
Quote:
Originally Posted by Colmike7 View Post
There's a java joke in here somewhere..
baddog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 12:54 PM   #28
ruff
I have a plan B
 
ruff's Avatar
 
Industry Role:
Join Date: Aug 2004
Location: Seattle - Miami - St Kitts
Posts: 5,501
When I was in school the only option was Fortran. So try some of that programming, you could work for NASA or Elon Musk. Of course, you're going to need more than one cup of coffee!
__________________
CryptoFeeds
ruff is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 01:00 PM   #29
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Quote:
Originally Posted by ruff View Post
When I was in school the only option was Fortran. So try some of that programming, you could work for NASA or Elon Musk. Of course, you're going to need more than one cup of coffee!
Ugh, no thanks. In college I had to do Fortran 95 and Maple at the same time in one of the classes. It sucked.

I did COBOL for a little bit, too. Wasn't paying enough.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 04:21 PM   #30
fuzebox
making it rain
 
fuzebox's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,009
Quote:
Originally Posted by k0nr4d View Post
No one ever said PHP was a good programming language...

fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 04:29 PM   #31
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by Colmike7 View Post
Ugh, no thanks. In college I had to do Fortran 95 and Maple at the same time in one of the classes. It sucked.

I did COBOL for a little bit, too. Wasn't paying enough.
One semester I took Assembler, Advanced COBOL and BASIC. Assembler and COBOL were both 6 credit courses and BASIC was a normal 3 credit course. First day of class I went to the BASIC instructor and told him "I won't be in any classes but if you will tell me when the tests are I will show up for every one", and he said ok.

I spent all my free time in the computer lab that semester, lol. One test, he brought to me in the lab because I had somehow forgotten about it and missed class that night.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-18-2020, 05:33 PM   #32
RyuLion
 
RyuLion's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: San Diego
Posts: 32,174
Quote:
Originally Posted by Colmike7 View Post
There's a java joke in here somewhere..
Programmer character at its best!
__________________

Adult Biz Consultant A tech head since 1995
RyuLion is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-19-2020, 01:22 AM   #33
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,381

Quote:
Originally Posted by Mr Pheer View Post
So I have this array like this

Code:
[location] => 2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149
What I want to do, is make it into three separate variables, like this

Code:
$city = 'Las Vegas';
$region = 'Nevada';
$zipcode = '89149';
How do I do that?
Pff... Now look how the PHP pro's do it ;)

Code:
preg_match('/City: (.*?)\n.*?Region: (.*?)\n.*?Zip Code: (.*?)$/s', $location, $matches);
array_shift($matches);
list($city, $region, $zipcode) = $matches;
Only 3 lines of code. We call it optimization, bro

P.S. Some people say my code sux. That because it's mostly unreadable like the one above. They write for people, I write for machines. This is why it looks so strange, but it much more compact and faster than the code, most coders are used to produce (with all those classes etc). PHP is not C++ and the server resources are very limited.
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-19-2020, 01:56 AM   #34
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Quote:
Originally Posted by CyberSEO View Post
Only 3 lines of code. We call it optimization, bro
While I will admit - short, elegant, you are firing up the regex engine. I actually timed the execution for shits to see which works fastest (adding an echo of the output at the end for fairness in each):

0.0002028942108 (konrad v1)
0.0002288818359 (konrad v2)
0.0003898143768 (cyberseo)
0.0011749267578 (sarettah)

We are of course talking about 1/10000ths of a second difference here
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-19-2020, 04:56 AM   #35
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,381
Actually not Depends on which operating system and which PHP engine you run it ;) And maybe in this particular case your code will be a bit faster (but the PHP code itself is larger). However in the more complicated cases (which we usually have a deal with, right?), regexp is much more effective by speed and that's a fact.

So, if you want to do a string replace or find a fixed text, course you will be using simple string functions. But if you need to find some brain-breaking pattern, you will be using regexp. That's what it designed for.

E.g. is the qsort algorithm the fastest and optimized one? You may say "not", because we can find lot of cases when it will be slow like a turtle, but... in general cases it faster that other more specific sorting algos. The same applies to regexp. Sometimes (in simplest cases) it really slower, but in general cases when you work with patterns, it's the fastest method. Don't you agree? ;)
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-19-2020, 05:06 AM   #36
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Quote:
Originally Posted by CyberSEO View Post
Actually not Depends on which operating system and which PHP engine you run it ;) And maybe in this particular case your code will be a bit faster (but the PHP code itself is larger). However in the more complicated cases (which we usually have a deal with, right?), regexp is much more effective by speed and that's a fact.

If you want to do a string replace or find a fixed text, course you will be using simple string functions. But if you need to find some brain-breaking pattern, you will be using regexp. That's what it designed for.
You are right - regex has it's place when it's a more complicated thing. In this particular case though string replace is faster. Either way like I said we're battling over 1/10000th of a second so in reality it makes no difference.

It is interesting though how there's so many ways to do it and the huge variance in execution speed with one way taking 5-6x as long to execute despite basically being exactly the same thing.
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-19-2020, 08:29 AM   #37
Mr Pheer
Living inside your head.
 
Mr Pheer's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: In your AirBNB
Posts: 20,468
Regex makes my head hurt. You fuck up one character and you've opened your script to shit like php injection hacks. Thanks for the code though
Mr Pheer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-19-2020, 12:35 PM   #38
PornDude
I'm still broke.
 
PornDude's Avatar
 
Industry Role:
Join Date: Jul 2008
Location: WildWildWest
Posts: 3,084
It's good to see k0nr4d helping people
__________________
PornDude.com 🔥

PornWebmasters.com 🤑

MyGaySites.com 🤭

PornDudeCasting.com 🚀
PornDude is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
las, separate, variables, vegas;, 89149;, $zipcode, nevada;, eek7, $region, $city, code, array, [location], 2020-10-16, php, 0408pm, zip, nevada, region, city, vegas



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.