String Replace for 8000 Company Names Iteration with PHP (Slug)Find ASCII codes and replace with...
Find a point shared by maximum segments
Air travel with refrigerated insulin
PTIJ: Which Dr. Seuss books should one obtain?
What are the consequences of changing the number of hours in a day?
Connection Between Knot Theory and Number Theory
How to evaluate the research level of a paper before any publication?
How do I lift the insulation blower into the attic?
Hot air balloons as primitive bombers
What is it called when someone votes for an option that's not their first choice?
Is it okay for a cleric of life to use spells like Animate Dead and/or Contagion?
Not hide and seek
Weird lines in Microsoft Word
What is the meaning of "You've never met a graph you didn't like?"
C++ lambda syntax
Is Crypto.generateMac method work exactly the same as Mac and SecretKeySpec java classes
How to test the sharpness of a knife?
1 John in Luther’s Bibel
How can an organ that provides biological immortality be unable to regenerate?
Strange behavior of Out[]
Can creatures abilities target that creature itself?
How can a new country break out from a developed country without war?
Script to load the ISS location and data
Pre-Employment Background Check With Consent For Future Checks
Would this string work as string?
String Replace for 8000 Company Names Iteration with PHP (Slug)
Find ASCII codes and replace with charactersPHP List Iterationreplace() for translating color namesAddress filter with PHP using regexPHP class for reading DTDReplace spaces with '%20'Replace string in fileRecursively replace string placeholders with parameterized phrasesDictionary iteration with many loopsdesign pattern for iteration php
$begingroup$
I wrote most of this working and beginner PHP script and I'd appreciate it if you would possibly review it and help me to replace slugCompany
method (which only iterates ~8000 times) in the UpdateStocks
class with a faster or simpler method.
Method:
/**
*
* @return a string of company name without common words to be embedded in the URL
*/
public static function slugCompany($c){
$c=strtolower($c);
$c=preg_replace('/[^da-zs]/i', '', $c);
$words=self::COMPANY_STOPWORDS;
$c=preg_replace('/b('.$words.')b/i', '', $c);
$c=preg_replace('/(s+)/i', '-', trim($c));
return $c;
}
Constant:
const COMPANY_STOPWORDS = '11000th|american|and|a|beneficial|bond|b|class|common|company|corporation|corp|commodity|cumulative|co|c|daily|dep|depositary|depository|debentures|diversified|due|d|each|etf|equal|equity|exchange|e|financial|fund|fixedtofloating|fixed|floating|f|group|g|healthcare|holdings|holding|h|inc|incorporated|interests|interest|in|index|income|i|junior|j|k|liability|limited|lp|llc|ltd|long|l|markets|maturity|municipal|muni|monthly|m|noncumulative|notes|no|n|of|one|or|o|portfolio|pay|partnership|partner|par|perpetual|per|perp|pfd|preference|preferred|p|q|redeemable|repstg|representing|represents|rate|r|sa|smallcap|series|shs|shares|share|short|stock|subordinated|ser|senior|s|the|three|term|to|traded|trust|two|t|ultrashort|ultra|u|value|v|warrant|weight|w|x|y|z';
Call:
$cn=strtolower(UpdateStocks::slugCompany($s["quote"]["companyName"])); // slug company
Part of Input (Last tab, Name of Company):
A 2019-01-04 AGILENT TECHNOLOGIES INC
AA 2019-01-04 ALCOA CORP
AAAU 2019-01-04 PERTH MINT PHYSICAL GOLD ETF
AABA 2019-01-04 ALTABA INC
AAC 2019-01-04 AAC HOLDINGS INC
AADR 2019-01-04 ADVISORSHARES DORSEY WRIGHT
AAL 2019-01-04 AMERICAN AIRLINES GROUP INC
AAMC 2019-01-04 ALTISOURCE ASSET MANAGEMENT
AAME 2019-01-04 ATLANTIC AMERICAN CORP
AAN 2019-01-04 AARON'S INC
AAOI 2019-01-04 APPLIED OPTOELECTRONICS INC
AAON 2019-01-04 AAON INC
AAP 2019-01-04 ADVANCE AUTO PARTS INC
AAPL 2019-01-04 APPLE INC
AAT 2019-01-04 AMERICAN ASSETS TRUST INC
AAU 2019-01-04 ALMADEN MINERALS LTD - B
AAWW 2019-01-04 ATLAS AIR WORLDWIDE HOLDINGS
AAXJ 2019-01-04 ISHARES MSCI ALL COUNTRY ASI
AAXN 2019-01-04 AXON ENTERPRISE INC
AB 2019-01-04 ALLIANCEBERNSTEIN HOLDING LP
ABAC 2019-01-04 RENMIN TIANLI GROUP INC
ABB 2019-01-04 ABB LTD-SPON ADR
ABBV 2019-01-04 ABBVIE INC
ABC 2019-01-04 AMERISOURCEBERGEN CORP
ABCB 2019-01-04 AMERIS BANCORP
ABDC 2019-01-04 ALCENTRA CAPITAL CORP
ABEO 2019-01-04 ABEONA THERAPEUTICS INC
ABEOW 2019-01-04
ABEV 2019-01-04 AMBEV SA-ADR
ABG 2019-01-04 ASBURY AUTOMOTIVE GROUP
ABIL 2019-01-04 ABILITY INC
ABIO 2019-01-04 ARCA BIOPHARMA INC
ABM 2019-01-04 ABM INDUSTRIES INC
ABMD 2019-01-04 ABIOMED INC
ABR 2019-01-04 ARBOR REALTY TRUST INC
ABR-A 2019-01-04
ABR-B 2019-01-04
ABR-C 2019-01-04
ABT 2019-01-04 ABBOTT LABORATORIES
ABTX 2019-01-04 ALLEGIANCE BANCSHARES INC
ABUS 2019-01-04 ARBUTUS BIOPHARMA CORP
AC 2019-01-04 ASSOCIATED CAPITAL GROUP - A
ACA 2019-01-04 ARCOSA INC
ACAD 2019-01-04 ACADIA PHARMACEUTICALS INC
ACB 2019-01-04 AURORA CANNABIS INC
ACBI 2019-01-04 ATLANTIC CAPITAL BANCSHARES
ACC 2019-01-04 AMERICAN CAMPUS COMMUNITIES
ACCO 2019-01-04 ACCO BRANDS CORP
ACER 2019-01-04 ACER THERAPEUTICS INC
ACES 2019-01-04 ALPS CLEAN ENERGY ETF
ACET 2019-01-04 ACETO CORP
ACGL 2019-01-04 ARCH CAPITAL GROUP LTD
ACGLO 2019-01-04
ACGLP 2019-01-04
ACH 2019-01-04 ALUMINUM CORP OF CHINA-ADR
ACHC 2019-01-04 ACADIA HEALTHCARE CO INC
ACHN 2019-01-04 ACHILLION PHARMACEUTICALS
ACHV 2019-01-04 ACHIEVE LIFE SCIENCES INC
ACIA 2019-01-04 ACACIA COMMUNICATIONS INC
ACIM 2019-01-04 SPDR MSCI ACWI IMI ETF
ACIU 2019-01-04 AC IMMUNE SA
ACIW 2019-01-04 ACI WORLDWIDE INC
ACLS 2019-01-04 AXCELIS TECHNOLOGIES INC
ACM 2019-01-04 AECOM
ACMR 2019-01-04 ACM RESEARCH INC-CLASS A
ACN 2019-01-04 ACCENTURE PLC-CL A
ACNB 2019-01-04 ACNB CORP
ACOR 2019-01-04 ACORDA THERAPEUTICS INC
ACP 2019-01-04 ABERDEEN INCOME CREDIT STRAT
ACRE 2019-01-04 ARES COMMERCIAL REAL ESTATE
ACRS 2019-01-04 ACLARIS THERAPEUTICS INC
ACRX 2019-01-04 ACELRX PHARMACEUTICALS INC
ACSG 2019-01-04 XTRACKERS MSCI ACWI EX USA E
ACSI 2019-01-04 AMERICAN CUSTOMER SATISFACTI
ACST 2019-01-04 ACASTI PHARMA INC
ACT 2019-01-04 ADVISORSHARES VICE ETF
ACTG 2019-01-04 ACACIA RESEARCH CORP
ACU 2019-01-04 ACME UNITED CORP
ACV 2019-01-04 ALLIANZGI DIVERSIFIED INCOME
ACWF 2019-01-04 ISHARES EDGE MSCI MULTIFACTO
ACWI 2019-01-04 ISHARES MSCI ACWI ETF
ACWV 2019-01-04 ISHARES EDGE MSCI MIN VOL GL
ACWX 2019-01-04 ISHARES MSCI ACWI EX US ETF
ACY 2019-01-04 AEROCENTURY CORP
ADAP 2019-01-04 ADAPTIMMUNE THERAPEUTICS-ADR
ADBE 2019-01-04 ADOBE INC
ADC 2019-01-04 AGREE REALTY CORP
ADES 2019-01-04 ADVANCED EMISSIONS SOLUTIONS
ADI 2019-01-04 ANALOG DEVICES INC
ADIL 2019-01-04 ADIAL PHARMACEUTICALS INC
ADILW 2019-01-04
ADM 2019-01-04 ARCHER-DANIELS-MIDLAND CO
ADMA 2019-01-04 ADMA BIOLOGICS INC
ADMP 2019-01-04 ADAMIS PHARMACEUTICALS CORP
ADMS 2019-01-04 ADAMAS PHARMACEUTICALS INC
ADNT 2019-01-04 ADIENT PLC
ADOM 2019-01-04 ADOMANI INC
ADP 2019-01-04 AUTOMATIC DATA PROCESSING
ADRA 2019-01-04 INVESCO BLDRS ASIA 50 ADR IN
ADRD 2019-01-04 INVESCO BLDRS DEVELOPED MARK
ADRE 2019-01-04 INVESCO BLDRS EMERGING MARKE
ADRO 2019-01-04 ADURO BIOTECH INC
ADRU 2019-01-04 INVESCO BLDRS EUROPE SELECT
ADS 2019-01-04 ALLIANCE DATA SYSTEMS CORP
ADSK 2019-01-04 AUTODESK INC
ADSW 2019-01-04 ADVANCED DISPOSAL SERVICES I
ADT 2019-01-04 ADT INC
ADTN 2019-01-04 ADTRAN INC
ADUS 2019-01-04 ADDUS HOMECARE CORP
ADVM 2019-01-04 ADVERUM BIOTECHNOLOGIES INC
ADX 2019-01-04 ADAMS DIVERSIFIED EQUITY
ADXS 2019-01-04 ADVAXIS INC
AE 2019-01-04 ADAMS RESOURCES & ENERGY INC
AEB 2019-01-04
AED 2019-01-04
AEE 2019-01-04 AMEREN CORPORATION
AEF 2019-01-04 ABERDEEN EM MRKT EQTY INC
AEG 2019-01-04 AEGON N.V.-NY REG SHR
AEGN 2019-01-04 AEGION CORP
AEH 2019-01-04
AEHR 2019-01-04 AEHR TEST SYSTEMS
AEIS 2019-01-04 ADVANCED ENERGY INDUSTRIES
AEL 2019-01-04 AMERICAN EQUITY INVT LIFE HL
AEM 2019-01-04 AGNICO EAGLE MINES LTD
AEMD 2019-01-04 AETHLON MEDICAL INC
AEO 2019-01-04 AMERICAN EAGLE OUTFITTERS
AEP 2019-01-04 AMERICAN ELECTRIC POWER
AER 2019-01-04 AERCAP HOLDINGS NV
AERI 2019-01-04 AERIE PHARMACEUTICALS INC
AES 2019-01-04 AES CORP
AETI 2019-01-04 AMERICAN ELECTRIC TECHNOLOGI
AEY 2019-01-04 ADDVANTAGE TECHNOLOGIES GRP
AEYE 2019-01-04 AUDIOEYE INC
AEZS 2019-01-04 AETERNA ZENTARIS INC
AFB 2019-01-04 ALLIANCE NATIONAL MUNI INC
AFC 2019-01-04
AFG 2019-01-04 AMERICAN FINANCIAL GROUP INC
AFGE 2019-01-04
AFGH 2019-01-04
AFH 2019-01-04 ATLAS FINANCIAL HOLDINGS INC
AFHBL 2019-01-04
AFI 2019-01-04 ARMSTRONG FLOORING INC
AFIF 2019-01-04 ANFIELD UNIVERSAL FIXED INCO
AFIN 2019-01-04 AMERICAN FINANCE TRUST INC
AFK 2019-01-04 VANECK VECTORS AFRICA INDEX
AFL 2019-01-04 AFLAC INC
AFMD 2019-01-04 AFFIMED NV
AFSI-A 2019-01-04
AFSI-B 2019-01-04
AFSI-C 2019-01-04
AFSI-D 2019-01-04
AFSI-E 2019-01-04
AFSI-F 2019-01-04
AFSS 2019-01-04
AFST 2019-01-04
AFT 2019-01-04 APOLLO SENIOR FLOATING RATE
AFTY 2019-01-04 CSOP FTSE CHINA A50 ETF
AG 2019-01-04 FIRST MAJESTIC SILVER CORP
AGCO 2019-01-04 AGCO CORP
AGD 2019-01-04 ABERDEEN GLBL DYN DIVID
AGE 2019-01-04 AGEX THERAPEUTICS INC
AGEN 2019-01-04 AGENUS INC
AGF 2019-01-04 DB AGRICULTURE LONG ETN
AGFS 2019-01-04 AGROFRESH SOLUTIONS INC
AGFSW 2019-01-04
AGG 2019-01-04 ISHARES CORE U.S. AGGREGATE
AGGE 2019-01-04 IQ ENHANCED CORE BOND US ETF
AGGP 2019-01-04 IQ ENHANCED CORE PLUS BOND U
AGGY 2019-01-04 WISDOMTREE YIELD ENHANCED US
AGI 2019-01-04 ALAMOS GOLD INC-CLASS A
AGIO 2019-01-04 AGIOS PHARMACEUTICALS INC
AGLE 2019-01-04 AEGLEA BIOTHERAPEUTICS INC
AGM 2019-01-04 FEDERAL AGRIC MTG CORP-CL C
AGM-A 2019-01-04
AGM-B 2019-01-04
AGM-C 2019-01-04
AGM.A 2019-01-04 FEDERAL AGRIC MTG CORP-CL A
AGMH 2019-01-04 AGM GROUP HOLDINGS INC
AGN 2019-01-04 ALLERGAN PLC
AGNC 2019-01-04 AGNC INVESTMENT CORP
AGNCB 2019-01-04
AGNCN 2019-01-04
AGND 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AGO 2019-01-04 ASSURED GUARANTY LTD
AGO-B 2019-01-04
AGO-E 2019-01-04
AGO-F 2019-01-04
AGQ 2019-01-04 PROSHARES ULTRA SILVER
AGR 2019-01-04 AVANGRID INC
AGRO 2019-01-04 ADECOAGRO SA
AGRX 2019-01-04 AGILE THERAPEUTICS INC
AGS 2019-01-04 PLAYAGS INC
AGT 2019-01-04 ISHARES ARGENTINA
AGTC 2019-01-04 APPLIED GENETIC TECHNOLOGIES
AGX 2019-01-04 ARGAN INC
AGYS 2019-01-04 AGILYSYS INC
AGZ 2019-01-04 ISHARES AGENCY BOND ETF
AGZD 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AHC 2019-01-04 A H BELO CORP-A
AHH 2019-01-04 ARMADA HOFFLER PROPERTIES IN
AHL 2019-01-04 ASPEN INSURANCE HOLDINGS LTD
AHL-C 2019-01-04
AHL-D 2019-01-04
AHPI 2019-01-04 ALLIED HEALTHCARE PRODUCTS
AHT 2019-01-04 ASHFORD HOSPITALITY TRUST
AHT-D 2019-01-04
AHT-F 2019-01-04
AHT-G 2019-01-04
AHT-H 2019-01-04
AHT-I 2019-01-04
AI 2019-01-04 ARLINGTON ASSET INVESTMENT-A
AI-B 2019-01-04
AIA 2019-01-04 ISHARES ASIA 50 ETF
AIC 2019-01-04
AIEQ 2019-01-04 AI POWERED EQUITY ETF
AIF 2019-01-04 APOLLO TACTICAL INCOME FUND
AIG 2019-01-04 AMERICAN INTERNATIONAL GROUP
AIG+ 2019-01-04
AIHS 2019-01-04 SENMIAO TECHNOLOGY LTD
AIIQ 2019-01-04 AI POWERED INTERNATIONAL EQU
AIMC 2019-01-04 ALTRA INDUSTRIAL MOTION CORP
AIMT 2019-01-04 AIMMUNE THERAPEUTICS INC
AIN 2019-01-04 ALBANY INTL CORP-CL A
AINC 2019-01-04 ASHFORD INC
AINV 2019-01-04 APOLLO INVESTMENT CORP
AIPT 2019-01-04 PRECISION THERAPEUTICS INC
AIQ 2019-01-04 Global X Future Analytics TE
AIR 2019-01-04 AAR CORP
AIRG 2019-01-04 AIRGAIN INC
AIRI 2019-01-04 AIR INDUSTRIES GROUP
AIRR 2019-01-04 FIRST TRUST RBA AMERICAN IND
AIRT 2019-01-04 AIR T INC
AIT 2019-01-04 APPLIED INDUSTRIAL TECH INC
AIV 2019-01-04 APARTMENT INVT & MGMT CO -A
AIV-A 2019-01-04
AIW 2019-01-04
AIY 2019-01-04
AIZ 2019-01-04 ASSURANT INC
AIZP 2019-01-04
AJG 2019-01-04 ARTHUR J GALLAGHER & CO
AJRD 2019-01-04 AEROJET ROCKETDYNE HOLDINGS
AJX 2019-01-04 GREAT AJAX CORP
AJXA 2019-01-04
AKAM 2019-01-04 AKAMAI TECHNOLOGIES INC
AKAO 2019-01-04 ACHAOGEN INC
AKBA 2019-01-04 AKEBIA THERAPEUTICS INC
AKCA 2019-01-04 AKCEA THERAPEUTICS INC
AKER 2019-01-04 AKERS BIOSCIENCES INC
AKG 2019-01-04 ASANKO GOLD INC
AKO.A 2019-01-04 EMBOTELLADORA ANDINA-ADR A
AKO.B 2019-01-04 EMBOTELLADORA ANDINA-ADR B
AKP 2019-01-04 ALLIANCE CALIF MUNI INCOME
AKR 2019-01-04 ACADIA REALTY TRUST
AKRX 2019-01-04 AKORN INC
AKS 2019-01-04 AK STEEL HOLDING CORP
AKTS 2019-01-04 AKOUSTIS TECHNOLOGIES INC
AKTX 2019-01-04 AKARI THERAPEUTICS PLC-ADR
AL 2019-01-04 AIR LEASE CORP
ALAC 2019-01-04 ALBERTON ACQUISITION CORP
ALACR 2019-01-04 ALBERTON ACQUISITION CO-RTS
ALACU 2019-01-04 ALBERTON ACQUISITION CORP
ALACW 2019-01-04
ALB 2019-01-04 ALBEMARLE CORP
ALBO 2019-01-04 ALBIREO PHARMA INC
ALCO 2019-01-04 ALICO INC
ALD 2019-01-04 WISDOMTREE ASIA LOCAL DEBT
ALDR 2019-01-04 ALDER BIOPHARMACEUTICALS INC
ALDX 2019-01-04 ALDEYRA THERAPEUTICS INC
ALE 2019-01-04 ALLETE INC
ALEX 2019-01-04 ALEXANDER & BALDWIN INC
ALFA 2019-01-04 ALPHACLONE ALTERNATIVE ALPHA
ALG 2019-01-04 ALAMO GROUP INC
ALGN 2019-01-04 ALIGN TECHNOLOGY INC
ALGR 2019-01-04 ALLEGRO MERGER CORP
ALGRR 2019-01-04 ALLEGRO MERGER CORP-RTS
ALGRU 2019-01-04 ALLEGRO MERGER CORP
ALGRW 2019-01-04
ALGT 2019-01-04 ALLEGIANT TRAVEL CO
ALIM 2019-01-04 ALIMERA SCIENCES INC
ALJJ 2019-01-04 ALJ REGIONAL HOLDINGS INC
ALK 2019-01-04 ALASKA AIR GROUP INC
ALKS 2019-01-04 ALKERMES PLC
ALL 2019-01-04 ALLSTATE CORP
Desired Output Example (for URLs):
agilent-technologies
php7.1
performance beginner php strings regex
$endgroup$
add a comment |
$begingroup$
I wrote most of this working and beginner PHP script and I'd appreciate it if you would possibly review it and help me to replace slugCompany
method (which only iterates ~8000 times) in the UpdateStocks
class with a faster or simpler method.
Method:
/**
*
* @return a string of company name without common words to be embedded in the URL
*/
public static function slugCompany($c){
$c=strtolower($c);
$c=preg_replace('/[^da-zs]/i', '', $c);
$words=self::COMPANY_STOPWORDS;
$c=preg_replace('/b('.$words.')b/i', '', $c);
$c=preg_replace('/(s+)/i', '-', trim($c));
return $c;
}
Constant:
const COMPANY_STOPWORDS = '11000th|american|and|a|beneficial|bond|b|class|common|company|corporation|corp|commodity|cumulative|co|c|daily|dep|depositary|depository|debentures|diversified|due|d|each|etf|equal|equity|exchange|e|financial|fund|fixedtofloating|fixed|floating|f|group|g|healthcare|holdings|holding|h|inc|incorporated|interests|interest|in|index|income|i|junior|j|k|liability|limited|lp|llc|ltd|long|l|markets|maturity|municipal|muni|monthly|m|noncumulative|notes|no|n|of|one|or|o|portfolio|pay|partnership|partner|par|perpetual|per|perp|pfd|preference|preferred|p|q|redeemable|repstg|representing|represents|rate|r|sa|smallcap|series|shs|shares|share|short|stock|subordinated|ser|senior|s|the|three|term|to|traded|trust|two|t|ultrashort|ultra|u|value|v|warrant|weight|w|x|y|z';
Call:
$cn=strtolower(UpdateStocks::slugCompany($s["quote"]["companyName"])); // slug company
Part of Input (Last tab, Name of Company):
A 2019-01-04 AGILENT TECHNOLOGIES INC
AA 2019-01-04 ALCOA CORP
AAAU 2019-01-04 PERTH MINT PHYSICAL GOLD ETF
AABA 2019-01-04 ALTABA INC
AAC 2019-01-04 AAC HOLDINGS INC
AADR 2019-01-04 ADVISORSHARES DORSEY WRIGHT
AAL 2019-01-04 AMERICAN AIRLINES GROUP INC
AAMC 2019-01-04 ALTISOURCE ASSET MANAGEMENT
AAME 2019-01-04 ATLANTIC AMERICAN CORP
AAN 2019-01-04 AARON'S INC
AAOI 2019-01-04 APPLIED OPTOELECTRONICS INC
AAON 2019-01-04 AAON INC
AAP 2019-01-04 ADVANCE AUTO PARTS INC
AAPL 2019-01-04 APPLE INC
AAT 2019-01-04 AMERICAN ASSETS TRUST INC
AAU 2019-01-04 ALMADEN MINERALS LTD - B
AAWW 2019-01-04 ATLAS AIR WORLDWIDE HOLDINGS
AAXJ 2019-01-04 ISHARES MSCI ALL COUNTRY ASI
AAXN 2019-01-04 AXON ENTERPRISE INC
AB 2019-01-04 ALLIANCEBERNSTEIN HOLDING LP
ABAC 2019-01-04 RENMIN TIANLI GROUP INC
ABB 2019-01-04 ABB LTD-SPON ADR
ABBV 2019-01-04 ABBVIE INC
ABC 2019-01-04 AMERISOURCEBERGEN CORP
ABCB 2019-01-04 AMERIS BANCORP
ABDC 2019-01-04 ALCENTRA CAPITAL CORP
ABEO 2019-01-04 ABEONA THERAPEUTICS INC
ABEOW 2019-01-04
ABEV 2019-01-04 AMBEV SA-ADR
ABG 2019-01-04 ASBURY AUTOMOTIVE GROUP
ABIL 2019-01-04 ABILITY INC
ABIO 2019-01-04 ARCA BIOPHARMA INC
ABM 2019-01-04 ABM INDUSTRIES INC
ABMD 2019-01-04 ABIOMED INC
ABR 2019-01-04 ARBOR REALTY TRUST INC
ABR-A 2019-01-04
ABR-B 2019-01-04
ABR-C 2019-01-04
ABT 2019-01-04 ABBOTT LABORATORIES
ABTX 2019-01-04 ALLEGIANCE BANCSHARES INC
ABUS 2019-01-04 ARBUTUS BIOPHARMA CORP
AC 2019-01-04 ASSOCIATED CAPITAL GROUP - A
ACA 2019-01-04 ARCOSA INC
ACAD 2019-01-04 ACADIA PHARMACEUTICALS INC
ACB 2019-01-04 AURORA CANNABIS INC
ACBI 2019-01-04 ATLANTIC CAPITAL BANCSHARES
ACC 2019-01-04 AMERICAN CAMPUS COMMUNITIES
ACCO 2019-01-04 ACCO BRANDS CORP
ACER 2019-01-04 ACER THERAPEUTICS INC
ACES 2019-01-04 ALPS CLEAN ENERGY ETF
ACET 2019-01-04 ACETO CORP
ACGL 2019-01-04 ARCH CAPITAL GROUP LTD
ACGLO 2019-01-04
ACGLP 2019-01-04
ACH 2019-01-04 ALUMINUM CORP OF CHINA-ADR
ACHC 2019-01-04 ACADIA HEALTHCARE CO INC
ACHN 2019-01-04 ACHILLION PHARMACEUTICALS
ACHV 2019-01-04 ACHIEVE LIFE SCIENCES INC
ACIA 2019-01-04 ACACIA COMMUNICATIONS INC
ACIM 2019-01-04 SPDR MSCI ACWI IMI ETF
ACIU 2019-01-04 AC IMMUNE SA
ACIW 2019-01-04 ACI WORLDWIDE INC
ACLS 2019-01-04 AXCELIS TECHNOLOGIES INC
ACM 2019-01-04 AECOM
ACMR 2019-01-04 ACM RESEARCH INC-CLASS A
ACN 2019-01-04 ACCENTURE PLC-CL A
ACNB 2019-01-04 ACNB CORP
ACOR 2019-01-04 ACORDA THERAPEUTICS INC
ACP 2019-01-04 ABERDEEN INCOME CREDIT STRAT
ACRE 2019-01-04 ARES COMMERCIAL REAL ESTATE
ACRS 2019-01-04 ACLARIS THERAPEUTICS INC
ACRX 2019-01-04 ACELRX PHARMACEUTICALS INC
ACSG 2019-01-04 XTRACKERS MSCI ACWI EX USA E
ACSI 2019-01-04 AMERICAN CUSTOMER SATISFACTI
ACST 2019-01-04 ACASTI PHARMA INC
ACT 2019-01-04 ADVISORSHARES VICE ETF
ACTG 2019-01-04 ACACIA RESEARCH CORP
ACU 2019-01-04 ACME UNITED CORP
ACV 2019-01-04 ALLIANZGI DIVERSIFIED INCOME
ACWF 2019-01-04 ISHARES EDGE MSCI MULTIFACTO
ACWI 2019-01-04 ISHARES MSCI ACWI ETF
ACWV 2019-01-04 ISHARES EDGE MSCI MIN VOL GL
ACWX 2019-01-04 ISHARES MSCI ACWI EX US ETF
ACY 2019-01-04 AEROCENTURY CORP
ADAP 2019-01-04 ADAPTIMMUNE THERAPEUTICS-ADR
ADBE 2019-01-04 ADOBE INC
ADC 2019-01-04 AGREE REALTY CORP
ADES 2019-01-04 ADVANCED EMISSIONS SOLUTIONS
ADI 2019-01-04 ANALOG DEVICES INC
ADIL 2019-01-04 ADIAL PHARMACEUTICALS INC
ADILW 2019-01-04
ADM 2019-01-04 ARCHER-DANIELS-MIDLAND CO
ADMA 2019-01-04 ADMA BIOLOGICS INC
ADMP 2019-01-04 ADAMIS PHARMACEUTICALS CORP
ADMS 2019-01-04 ADAMAS PHARMACEUTICALS INC
ADNT 2019-01-04 ADIENT PLC
ADOM 2019-01-04 ADOMANI INC
ADP 2019-01-04 AUTOMATIC DATA PROCESSING
ADRA 2019-01-04 INVESCO BLDRS ASIA 50 ADR IN
ADRD 2019-01-04 INVESCO BLDRS DEVELOPED MARK
ADRE 2019-01-04 INVESCO BLDRS EMERGING MARKE
ADRO 2019-01-04 ADURO BIOTECH INC
ADRU 2019-01-04 INVESCO BLDRS EUROPE SELECT
ADS 2019-01-04 ALLIANCE DATA SYSTEMS CORP
ADSK 2019-01-04 AUTODESK INC
ADSW 2019-01-04 ADVANCED DISPOSAL SERVICES I
ADT 2019-01-04 ADT INC
ADTN 2019-01-04 ADTRAN INC
ADUS 2019-01-04 ADDUS HOMECARE CORP
ADVM 2019-01-04 ADVERUM BIOTECHNOLOGIES INC
ADX 2019-01-04 ADAMS DIVERSIFIED EQUITY
ADXS 2019-01-04 ADVAXIS INC
AE 2019-01-04 ADAMS RESOURCES & ENERGY INC
AEB 2019-01-04
AED 2019-01-04
AEE 2019-01-04 AMEREN CORPORATION
AEF 2019-01-04 ABERDEEN EM MRKT EQTY INC
AEG 2019-01-04 AEGON N.V.-NY REG SHR
AEGN 2019-01-04 AEGION CORP
AEH 2019-01-04
AEHR 2019-01-04 AEHR TEST SYSTEMS
AEIS 2019-01-04 ADVANCED ENERGY INDUSTRIES
AEL 2019-01-04 AMERICAN EQUITY INVT LIFE HL
AEM 2019-01-04 AGNICO EAGLE MINES LTD
AEMD 2019-01-04 AETHLON MEDICAL INC
AEO 2019-01-04 AMERICAN EAGLE OUTFITTERS
AEP 2019-01-04 AMERICAN ELECTRIC POWER
AER 2019-01-04 AERCAP HOLDINGS NV
AERI 2019-01-04 AERIE PHARMACEUTICALS INC
AES 2019-01-04 AES CORP
AETI 2019-01-04 AMERICAN ELECTRIC TECHNOLOGI
AEY 2019-01-04 ADDVANTAGE TECHNOLOGIES GRP
AEYE 2019-01-04 AUDIOEYE INC
AEZS 2019-01-04 AETERNA ZENTARIS INC
AFB 2019-01-04 ALLIANCE NATIONAL MUNI INC
AFC 2019-01-04
AFG 2019-01-04 AMERICAN FINANCIAL GROUP INC
AFGE 2019-01-04
AFGH 2019-01-04
AFH 2019-01-04 ATLAS FINANCIAL HOLDINGS INC
AFHBL 2019-01-04
AFI 2019-01-04 ARMSTRONG FLOORING INC
AFIF 2019-01-04 ANFIELD UNIVERSAL FIXED INCO
AFIN 2019-01-04 AMERICAN FINANCE TRUST INC
AFK 2019-01-04 VANECK VECTORS AFRICA INDEX
AFL 2019-01-04 AFLAC INC
AFMD 2019-01-04 AFFIMED NV
AFSI-A 2019-01-04
AFSI-B 2019-01-04
AFSI-C 2019-01-04
AFSI-D 2019-01-04
AFSI-E 2019-01-04
AFSI-F 2019-01-04
AFSS 2019-01-04
AFST 2019-01-04
AFT 2019-01-04 APOLLO SENIOR FLOATING RATE
AFTY 2019-01-04 CSOP FTSE CHINA A50 ETF
AG 2019-01-04 FIRST MAJESTIC SILVER CORP
AGCO 2019-01-04 AGCO CORP
AGD 2019-01-04 ABERDEEN GLBL DYN DIVID
AGE 2019-01-04 AGEX THERAPEUTICS INC
AGEN 2019-01-04 AGENUS INC
AGF 2019-01-04 DB AGRICULTURE LONG ETN
AGFS 2019-01-04 AGROFRESH SOLUTIONS INC
AGFSW 2019-01-04
AGG 2019-01-04 ISHARES CORE U.S. AGGREGATE
AGGE 2019-01-04 IQ ENHANCED CORE BOND US ETF
AGGP 2019-01-04 IQ ENHANCED CORE PLUS BOND U
AGGY 2019-01-04 WISDOMTREE YIELD ENHANCED US
AGI 2019-01-04 ALAMOS GOLD INC-CLASS A
AGIO 2019-01-04 AGIOS PHARMACEUTICALS INC
AGLE 2019-01-04 AEGLEA BIOTHERAPEUTICS INC
AGM 2019-01-04 FEDERAL AGRIC MTG CORP-CL C
AGM-A 2019-01-04
AGM-B 2019-01-04
AGM-C 2019-01-04
AGM.A 2019-01-04 FEDERAL AGRIC MTG CORP-CL A
AGMH 2019-01-04 AGM GROUP HOLDINGS INC
AGN 2019-01-04 ALLERGAN PLC
AGNC 2019-01-04 AGNC INVESTMENT CORP
AGNCB 2019-01-04
AGNCN 2019-01-04
AGND 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AGO 2019-01-04 ASSURED GUARANTY LTD
AGO-B 2019-01-04
AGO-E 2019-01-04
AGO-F 2019-01-04
AGQ 2019-01-04 PROSHARES ULTRA SILVER
AGR 2019-01-04 AVANGRID INC
AGRO 2019-01-04 ADECOAGRO SA
AGRX 2019-01-04 AGILE THERAPEUTICS INC
AGS 2019-01-04 PLAYAGS INC
AGT 2019-01-04 ISHARES ARGENTINA
AGTC 2019-01-04 APPLIED GENETIC TECHNOLOGIES
AGX 2019-01-04 ARGAN INC
AGYS 2019-01-04 AGILYSYS INC
AGZ 2019-01-04 ISHARES AGENCY BOND ETF
AGZD 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AHC 2019-01-04 A H BELO CORP-A
AHH 2019-01-04 ARMADA HOFFLER PROPERTIES IN
AHL 2019-01-04 ASPEN INSURANCE HOLDINGS LTD
AHL-C 2019-01-04
AHL-D 2019-01-04
AHPI 2019-01-04 ALLIED HEALTHCARE PRODUCTS
AHT 2019-01-04 ASHFORD HOSPITALITY TRUST
AHT-D 2019-01-04
AHT-F 2019-01-04
AHT-G 2019-01-04
AHT-H 2019-01-04
AHT-I 2019-01-04
AI 2019-01-04 ARLINGTON ASSET INVESTMENT-A
AI-B 2019-01-04
AIA 2019-01-04 ISHARES ASIA 50 ETF
AIC 2019-01-04
AIEQ 2019-01-04 AI POWERED EQUITY ETF
AIF 2019-01-04 APOLLO TACTICAL INCOME FUND
AIG 2019-01-04 AMERICAN INTERNATIONAL GROUP
AIG+ 2019-01-04
AIHS 2019-01-04 SENMIAO TECHNOLOGY LTD
AIIQ 2019-01-04 AI POWERED INTERNATIONAL EQU
AIMC 2019-01-04 ALTRA INDUSTRIAL MOTION CORP
AIMT 2019-01-04 AIMMUNE THERAPEUTICS INC
AIN 2019-01-04 ALBANY INTL CORP-CL A
AINC 2019-01-04 ASHFORD INC
AINV 2019-01-04 APOLLO INVESTMENT CORP
AIPT 2019-01-04 PRECISION THERAPEUTICS INC
AIQ 2019-01-04 Global X Future Analytics TE
AIR 2019-01-04 AAR CORP
AIRG 2019-01-04 AIRGAIN INC
AIRI 2019-01-04 AIR INDUSTRIES GROUP
AIRR 2019-01-04 FIRST TRUST RBA AMERICAN IND
AIRT 2019-01-04 AIR T INC
AIT 2019-01-04 APPLIED INDUSTRIAL TECH INC
AIV 2019-01-04 APARTMENT INVT & MGMT CO -A
AIV-A 2019-01-04
AIW 2019-01-04
AIY 2019-01-04
AIZ 2019-01-04 ASSURANT INC
AIZP 2019-01-04
AJG 2019-01-04 ARTHUR J GALLAGHER & CO
AJRD 2019-01-04 AEROJET ROCKETDYNE HOLDINGS
AJX 2019-01-04 GREAT AJAX CORP
AJXA 2019-01-04
AKAM 2019-01-04 AKAMAI TECHNOLOGIES INC
AKAO 2019-01-04 ACHAOGEN INC
AKBA 2019-01-04 AKEBIA THERAPEUTICS INC
AKCA 2019-01-04 AKCEA THERAPEUTICS INC
AKER 2019-01-04 AKERS BIOSCIENCES INC
AKG 2019-01-04 ASANKO GOLD INC
AKO.A 2019-01-04 EMBOTELLADORA ANDINA-ADR A
AKO.B 2019-01-04 EMBOTELLADORA ANDINA-ADR B
AKP 2019-01-04 ALLIANCE CALIF MUNI INCOME
AKR 2019-01-04 ACADIA REALTY TRUST
AKRX 2019-01-04 AKORN INC
AKS 2019-01-04 AK STEEL HOLDING CORP
AKTS 2019-01-04 AKOUSTIS TECHNOLOGIES INC
AKTX 2019-01-04 AKARI THERAPEUTICS PLC-ADR
AL 2019-01-04 AIR LEASE CORP
ALAC 2019-01-04 ALBERTON ACQUISITION CORP
ALACR 2019-01-04 ALBERTON ACQUISITION CO-RTS
ALACU 2019-01-04 ALBERTON ACQUISITION CORP
ALACW 2019-01-04
ALB 2019-01-04 ALBEMARLE CORP
ALBO 2019-01-04 ALBIREO PHARMA INC
ALCO 2019-01-04 ALICO INC
ALD 2019-01-04 WISDOMTREE ASIA LOCAL DEBT
ALDR 2019-01-04 ALDER BIOPHARMACEUTICALS INC
ALDX 2019-01-04 ALDEYRA THERAPEUTICS INC
ALE 2019-01-04 ALLETE INC
ALEX 2019-01-04 ALEXANDER & BALDWIN INC
ALFA 2019-01-04 ALPHACLONE ALTERNATIVE ALPHA
ALG 2019-01-04 ALAMO GROUP INC
ALGN 2019-01-04 ALIGN TECHNOLOGY INC
ALGR 2019-01-04 ALLEGRO MERGER CORP
ALGRR 2019-01-04 ALLEGRO MERGER CORP-RTS
ALGRU 2019-01-04 ALLEGRO MERGER CORP
ALGRW 2019-01-04
ALGT 2019-01-04 ALLEGIANT TRAVEL CO
ALIM 2019-01-04 ALIMERA SCIENCES INC
ALJJ 2019-01-04 ALJ REGIONAL HOLDINGS INC
ALK 2019-01-04 ALASKA AIR GROUP INC
ALKS 2019-01-04 ALKERMES PLC
ALL 2019-01-04 ALLSTATE CORP
Desired Output Example (for URLs):
agilent-technologies
php7.1
performance beginner php strings regex
$endgroup$
$begingroup$
You wrote most of it, i.e. this is not your code? You also state: "desired output", does it not produce the desired output?
$endgroup$
– yuri
Mar 14 at 16:00
add a comment |
$begingroup$
I wrote most of this working and beginner PHP script and I'd appreciate it if you would possibly review it and help me to replace slugCompany
method (which only iterates ~8000 times) in the UpdateStocks
class with a faster or simpler method.
Method:
/**
*
* @return a string of company name without common words to be embedded in the URL
*/
public static function slugCompany($c){
$c=strtolower($c);
$c=preg_replace('/[^da-zs]/i', '', $c);
$words=self::COMPANY_STOPWORDS;
$c=preg_replace('/b('.$words.')b/i', '', $c);
$c=preg_replace('/(s+)/i', '-', trim($c));
return $c;
}
Constant:
const COMPANY_STOPWORDS = '11000th|american|and|a|beneficial|bond|b|class|common|company|corporation|corp|commodity|cumulative|co|c|daily|dep|depositary|depository|debentures|diversified|due|d|each|etf|equal|equity|exchange|e|financial|fund|fixedtofloating|fixed|floating|f|group|g|healthcare|holdings|holding|h|inc|incorporated|interests|interest|in|index|income|i|junior|j|k|liability|limited|lp|llc|ltd|long|l|markets|maturity|municipal|muni|monthly|m|noncumulative|notes|no|n|of|one|or|o|portfolio|pay|partnership|partner|par|perpetual|per|perp|pfd|preference|preferred|p|q|redeemable|repstg|representing|represents|rate|r|sa|smallcap|series|shs|shares|share|short|stock|subordinated|ser|senior|s|the|three|term|to|traded|trust|two|t|ultrashort|ultra|u|value|v|warrant|weight|w|x|y|z';
Call:
$cn=strtolower(UpdateStocks::slugCompany($s["quote"]["companyName"])); // slug company
Part of Input (Last tab, Name of Company):
A 2019-01-04 AGILENT TECHNOLOGIES INC
AA 2019-01-04 ALCOA CORP
AAAU 2019-01-04 PERTH MINT PHYSICAL GOLD ETF
AABA 2019-01-04 ALTABA INC
AAC 2019-01-04 AAC HOLDINGS INC
AADR 2019-01-04 ADVISORSHARES DORSEY WRIGHT
AAL 2019-01-04 AMERICAN AIRLINES GROUP INC
AAMC 2019-01-04 ALTISOURCE ASSET MANAGEMENT
AAME 2019-01-04 ATLANTIC AMERICAN CORP
AAN 2019-01-04 AARON'S INC
AAOI 2019-01-04 APPLIED OPTOELECTRONICS INC
AAON 2019-01-04 AAON INC
AAP 2019-01-04 ADVANCE AUTO PARTS INC
AAPL 2019-01-04 APPLE INC
AAT 2019-01-04 AMERICAN ASSETS TRUST INC
AAU 2019-01-04 ALMADEN MINERALS LTD - B
AAWW 2019-01-04 ATLAS AIR WORLDWIDE HOLDINGS
AAXJ 2019-01-04 ISHARES MSCI ALL COUNTRY ASI
AAXN 2019-01-04 AXON ENTERPRISE INC
AB 2019-01-04 ALLIANCEBERNSTEIN HOLDING LP
ABAC 2019-01-04 RENMIN TIANLI GROUP INC
ABB 2019-01-04 ABB LTD-SPON ADR
ABBV 2019-01-04 ABBVIE INC
ABC 2019-01-04 AMERISOURCEBERGEN CORP
ABCB 2019-01-04 AMERIS BANCORP
ABDC 2019-01-04 ALCENTRA CAPITAL CORP
ABEO 2019-01-04 ABEONA THERAPEUTICS INC
ABEOW 2019-01-04
ABEV 2019-01-04 AMBEV SA-ADR
ABG 2019-01-04 ASBURY AUTOMOTIVE GROUP
ABIL 2019-01-04 ABILITY INC
ABIO 2019-01-04 ARCA BIOPHARMA INC
ABM 2019-01-04 ABM INDUSTRIES INC
ABMD 2019-01-04 ABIOMED INC
ABR 2019-01-04 ARBOR REALTY TRUST INC
ABR-A 2019-01-04
ABR-B 2019-01-04
ABR-C 2019-01-04
ABT 2019-01-04 ABBOTT LABORATORIES
ABTX 2019-01-04 ALLEGIANCE BANCSHARES INC
ABUS 2019-01-04 ARBUTUS BIOPHARMA CORP
AC 2019-01-04 ASSOCIATED CAPITAL GROUP - A
ACA 2019-01-04 ARCOSA INC
ACAD 2019-01-04 ACADIA PHARMACEUTICALS INC
ACB 2019-01-04 AURORA CANNABIS INC
ACBI 2019-01-04 ATLANTIC CAPITAL BANCSHARES
ACC 2019-01-04 AMERICAN CAMPUS COMMUNITIES
ACCO 2019-01-04 ACCO BRANDS CORP
ACER 2019-01-04 ACER THERAPEUTICS INC
ACES 2019-01-04 ALPS CLEAN ENERGY ETF
ACET 2019-01-04 ACETO CORP
ACGL 2019-01-04 ARCH CAPITAL GROUP LTD
ACGLO 2019-01-04
ACGLP 2019-01-04
ACH 2019-01-04 ALUMINUM CORP OF CHINA-ADR
ACHC 2019-01-04 ACADIA HEALTHCARE CO INC
ACHN 2019-01-04 ACHILLION PHARMACEUTICALS
ACHV 2019-01-04 ACHIEVE LIFE SCIENCES INC
ACIA 2019-01-04 ACACIA COMMUNICATIONS INC
ACIM 2019-01-04 SPDR MSCI ACWI IMI ETF
ACIU 2019-01-04 AC IMMUNE SA
ACIW 2019-01-04 ACI WORLDWIDE INC
ACLS 2019-01-04 AXCELIS TECHNOLOGIES INC
ACM 2019-01-04 AECOM
ACMR 2019-01-04 ACM RESEARCH INC-CLASS A
ACN 2019-01-04 ACCENTURE PLC-CL A
ACNB 2019-01-04 ACNB CORP
ACOR 2019-01-04 ACORDA THERAPEUTICS INC
ACP 2019-01-04 ABERDEEN INCOME CREDIT STRAT
ACRE 2019-01-04 ARES COMMERCIAL REAL ESTATE
ACRS 2019-01-04 ACLARIS THERAPEUTICS INC
ACRX 2019-01-04 ACELRX PHARMACEUTICALS INC
ACSG 2019-01-04 XTRACKERS MSCI ACWI EX USA E
ACSI 2019-01-04 AMERICAN CUSTOMER SATISFACTI
ACST 2019-01-04 ACASTI PHARMA INC
ACT 2019-01-04 ADVISORSHARES VICE ETF
ACTG 2019-01-04 ACACIA RESEARCH CORP
ACU 2019-01-04 ACME UNITED CORP
ACV 2019-01-04 ALLIANZGI DIVERSIFIED INCOME
ACWF 2019-01-04 ISHARES EDGE MSCI MULTIFACTO
ACWI 2019-01-04 ISHARES MSCI ACWI ETF
ACWV 2019-01-04 ISHARES EDGE MSCI MIN VOL GL
ACWX 2019-01-04 ISHARES MSCI ACWI EX US ETF
ACY 2019-01-04 AEROCENTURY CORP
ADAP 2019-01-04 ADAPTIMMUNE THERAPEUTICS-ADR
ADBE 2019-01-04 ADOBE INC
ADC 2019-01-04 AGREE REALTY CORP
ADES 2019-01-04 ADVANCED EMISSIONS SOLUTIONS
ADI 2019-01-04 ANALOG DEVICES INC
ADIL 2019-01-04 ADIAL PHARMACEUTICALS INC
ADILW 2019-01-04
ADM 2019-01-04 ARCHER-DANIELS-MIDLAND CO
ADMA 2019-01-04 ADMA BIOLOGICS INC
ADMP 2019-01-04 ADAMIS PHARMACEUTICALS CORP
ADMS 2019-01-04 ADAMAS PHARMACEUTICALS INC
ADNT 2019-01-04 ADIENT PLC
ADOM 2019-01-04 ADOMANI INC
ADP 2019-01-04 AUTOMATIC DATA PROCESSING
ADRA 2019-01-04 INVESCO BLDRS ASIA 50 ADR IN
ADRD 2019-01-04 INVESCO BLDRS DEVELOPED MARK
ADRE 2019-01-04 INVESCO BLDRS EMERGING MARKE
ADRO 2019-01-04 ADURO BIOTECH INC
ADRU 2019-01-04 INVESCO BLDRS EUROPE SELECT
ADS 2019-01-04 ALLIANCE DATA SYSTEMS CORP
ADSK 2019-01-04 AUTODESK INC
ADSW 2019-01-04 ADVANCED DISPOSAL SERVICES I
ADT 2019-01-04 ADT INC
ADTN 2019-01-04 ADTRAN INC
ADUS 2019-01-04 ADDUS HOMECARE CORP
ADVM 2019-01-04 ADVERUM BIOTECHNOLOGIES INC
ADX 2019-01-04 ADAMS DIVERSIFIED EQUITY
ADXS 2019-01-04 ADVAXIS INC
AE 2019-01-04 ADAMS RESOURCES & ENERGY INC
AEB 2019-01-04
AED 2019-01-04
AEE 2019-01-04 AMEREN CORPORATION
AEF 2019-01-04 ABERDEEN EM MRKT EQTY INC
AEG 2019-01-04 AEGON N.V.-NY REG SHR
AEGN 2019-01-04 AEGION CORP
AEH 2019-01-04
AEHR 2019-01-04 AEHR TEST SYSTEMS
AEIS 2019-01-04 ADVANCED ENERGY INDUSTRIES
AEL 2019-01-04 AMERICAN EQUITY INVT LIFE HL
AEM 2019-01-04 AGNICO EAGLE MINES LTD
AEMD 2019-01-04 AETHLON MEDICAL INC
AEO 2019-01-04 AMERICAN EAGLE OUTFITTERS
AEP 2019-01-04 AMERICAN ELECTRIC POWER
AER 2019-01-04 AERCAP HOLDINGS NV
AERI 2019-01-04 AERIE PHARMACEUTICALS INC
AES 2019-01-04 AES CORP
AETI 2019-01-04 AMERICAN ELECTRIC TECHNOLOGI
AEY 2019-01-04 ADDVANTAGE TECHNOLOGIES GRP
AEYE 2019-01-04 AUDIOEYE INC
AEZS 2019-01-04 AETERNA ZENTARIS INC
AFB 2019-01-04 ALLIANCE NATIONAL MUNI INC
AFC 2019-01-04
AFG 2019-01-04 AMERICAN FINANCIAL GROUP INC
AFGE 2019-01-04
AFGH 2019-01-04
AFH 2019-01-04 ATLAS FINANCIAL HOLDINGS INC
AFHBL 2019-01-04
AFI 2019-01-04 ARMSTRONG FLOORING INC
AFIF 2019-01-04 ANFIELD UNIVERSAL FIXED INCO
AFIN 2019-01-04 AMERICAN FINANCE TRUST INC
AFK 2019-01-04 VANECK VECTORS AFRICA INDEX
AFL 2019-01-04 AFLAC INC
AFMD 2019-01-04 AFFIMED NV
AFSI-A 2019-01-04
AFSI-B 2019-01-04
AFSI-C 2019-01-04
AFSI-D 2019-01-04
AFSI-E 2019-01-04
AFSI-F 2019-01-04
AFSS 2019-01-04
AFST 2019-01-04
AFT 2019-01-04 APOLLO SENIOR FLOATING RATE
AFTY 2019-01-04 CSOP FTSE CHINA A50 ETF
AG 2019-01-04 FIRST MAJESTIC SILVER CORP
AGCO 2019-01-04 AGCO CORP
AGD 2019-01-04 ABERDEEN GLBL DYN DIVID
AGE 2019-01-04 AGEX THERAPEUTICS INC
AGEN 2019-01-04 AGENUS INC
AGF 2019-01-04 DB AGRICULTURE LONG ETN
AGFS 2019-01-04 AGROFRESH SOLUTIONS INC
AGFSW 2019-01-04
AGG 2019-01-04 ISHARES CORE U.S. AGGREGATE
AGGE 2019-01-04 IQ ENHANCED CORE BOND US ETF
AGGP 2019-01-04 IQ ENHANCED CORE PLUS BOND U
AGGY 2019-01-04 WISDOMTREE YIELD ENHANCED US
AGI 2019-01-04 ALAMOS GOLD INC-CLASS A
AGIO 2019-01-04 AGIOS PHARMACEUTICALS INC
AGLE 2019-01-04 AEGLEA BIOTHERAPEUTICS INC
AGM 2019-01-04 FEDERAL AGRIC MTG CORP-CL C
AGM-A 2019-01-04
AGM-B 2019-01-04
AGM-C 2019-01-04
AGM.A 2019-01-04 FEDERAL AGRIC MTG CORP-CL A
AGMH 2019-01-04 AGM GROUP HOLDINGS INC
AGN 2019-01-04 ALLERGAN PLC
AGNC 2019-01-04 AGNC INVESTMENT CORP
AGNCB 2019-01-04
AGNCN 2019-01-04
AGND 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AGO 2019-01-04 ASSURED GUARANTY LTD
AGO-B 2019-01-04
AGO-E 2019-01-04
AGO-F 2019-01-04
AGQ 2019-01-04 PROSHARES ULTRA SILVER
AGR 2019-01-04 AVANGRID INC
AGRO 2019-01-04 ADECOAGRO SA
AGRX 2019-01-04 AGILE THERAPEUTICS INC
AGS 2019-01-04 PLAYAGS INC
AGT 2019-01-04 ISHARES ARGENTINA
AGTC 2019-01-04 APPLIED GENETIC TECHNOLOGIES
AGX 2019-01-04 ARGAN INC
AGYS 2019-01-04 AGILYSYS INC
AGZ 2019-01-04 ISHARES AGENCY BOND ETF
AGZD 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AHC 2019-01-04 A H BELO CORP-A
AHH 2019-01-04 ARMADA HOFFLER PROPERTIES IN
AHL 2019-01-04 ASPEN INSURANCE HOLDINGS LTD
AHL-C 2019-01-04
AHL-D 2019-01-04
AHPI 2019-01-04 ALLIED HEALTHCARE PRODUCTS
AHT 2019-01-04 ASHFORD HOSPITALITY TRUST
AHT-D 2019-01-04
AHT-F 2019-01-04
AHT-G 2019-01-04
AHT-H 2019-01-04
AHT-I 2019-01-04
AI 2019-01-04 ARLINGTON ASSET INVESTMENT-A
AI-B 2019-01-04
AIA 2019-01-04 ISHARES ASIA 50 ETF
AIC 2019-01-04
AIEQ 2019-01-04 AI POWERED EQUITY ETF
AIF 2019-01-04 APOLLO TACTICAL INCOME FUND
AIG 2019-01-04 AMERICAN INTERNATIONAL GROUP
AIG+ 2019-01-04
AIHS 2019-01-04 SENMIAO TECHNOLOGY LTD
AIIQ 2019-01-04 AI POWERED INTERNATIONAL EQU
AIMC 2019-01-04 ALTRA INDUSTRIAL MOTION CORP
AIMT 2019-01-04 AIMMUNE THERAPEUTICS INC
AIN 2019-01-04 ALBANY INTL CORP-CL A
AINC 2019-01-04 ASHFORD INC
AINV 2019-01-04 APOLLO INVESTMENT CORP
AIPT 2019-01-04 PRECISION THERAPEUTICS INC
AIQ 2019-01-04 Global X Future Analytics TE
AIR 2019-01-04 AAR CORP
AIRG 2019-01-04 AIRGAIN INC
AIRI 2019-01-04 AIR INDUSTRIES GROUP
AIRR 2019-01-04 FIRST TRUST RBA AMERICAN IND
AIRT 2019-01-04 AIR T INC
AIT 2019-01-04 APPLIED INDUSTRIAL TECH INC
AIV 2019-01-04 APARTMENT INVT & MGMT CO -A
AIV-A 2019-01-04
AIW 2019-01-04
AIY 2019-01-04
AIZ 2019-01-04 ASSURANT INC
AIZP 2019-01-04
AJG 2019-01-04 ARTHUR J GALLAGHER & CO
AJRD 2019-01-04 AEROJET ROCKETDYNE HOLDINGS
AJX 2019-01-04 GREAT AJAX CORP
AJXA 2019-01-04
AKAM 2019-01-04 AKAMAI TECHNOLOGIES INC
AKAO 2019-01-04 ACHAOGEN INC
AKBA 2019-01-04 AKEBIA THERAPEUTICS INC
AKCA 2019-01-04 AKCEA THERAPEUTICS INC
AKER 2019-01-04 AKERS BIOSCIENCES INC
AKG 2019-01-04 ASANKO GOLD INC
AKO.A 2019-01-04 EMBOTELLADORA ANDINA-ADR A
AKO.B 2019-01-04 EMBOTELLADORA ANDINA-ADR B
AKP 2019-01-04 ALLIANCE CALIF MUNI INCOME
AKR 2019-01-04 ACADIA REALTY TRUST
AKRX 2019-01-04 AKORN INC
AKS 2019-01-04 AK STEEL HOLDING CORP
AKTS 2019-01-04 AKOUSTIS TECHNOLOGIES INC
AKTX 2019-01-04 AKARI THERAPEUTICS PLC-ADR
AL 2019-01-04 AIR LEASE CORP
ALAC 2019-01-04 ALBERTON ACQUISITION CORP
ALACR 2019-01-04 ALBERTON ACQUISITION CO-RTS
ALACU 2019-01-04 ALBERTON ACQUISITION CORP
ALACW 2019-01-04
ALB 2019-01-04 ALBEMARLE CORP
ALBO 2019-01-04 ALBIREO PHARMA INC
ALCO 2019-01-04 ALICO INC
ALD 2019-01-04 WISDOMTREE ASIA LOCAL DEBT
ALDR 2019-01-04 ALDER BIOPHARMACEUTICALS INC
ALDX 2019-01-04 ALDEYRA THERAPEUTICS INC
ALE 2019-01-04 ALLETE INC
ALEX 2019-01-04 ALEXANDER & BALDWIN INC
ALFA 2019-01-04 ALPHACLONE ALTERNATIVE ALPHA
ALG 2019-01-04 ALAMO GROUP INC
ALGN 2019-01-04 ALIGN TECHNOLOGY INC
ALGR 2019-01-04 ALLEGRO MERGER CORP
ALGRR 2019-01-04 ALLEGRO MERGER CORP-RTS
ALGRU 2019-01-04 ALLEGRO MERGER CORP
ALGRW 2019-01-04
ALGT 2019-01-04 ALLEGIANT TRAVEL CO
ALIM 2019-01-04 ALIMERA SCIENCES INC
ALJJ 2019-01-04 ALJ REGIONAL HOLDINGS INC
ALK 2019-01-04 ALASKA AIR GROUP INC
ALKS 2019-01-04 ALKERMES PLC
ALL 2019-01-04 ALLSTATE CORP
Desired Output Example (for URLs):
agilent-technologies
php7.1
performance beginner php strings regex
$endgroup$
I wrote most of this working and beginner PHP script and I'd appreciate it if you would possibly review it and help me to replace slugCompany
method (which only iterates ~8000 times) in the UpdateStocks
class with a faster or simpler method.
Method:
/**
*
* @return a string of company name without common words to be embedded in the URL
*/
public static function slugCompany($c){
$c=strtolower($c);
$c=preg_replace('/[^da-zs]/i', '', $c);
$words=self::COMPANY_STOPWORDS;
$c=preg_replace('/b('.$words.')b/i', '', $c);
$c=preg_replace('/(s+)/i', '-', trim($c));
return $c;
}
Constant:
const COMPANY_STOPWORDS = '11000th|american|and|a|beneficial|bond|b|class|common|company|corporation|corp|commodity|cumulative|co|c|daily|dep|depositary|depository|debentures|diversified|due|d|each|etf|equal|equity|exchange|e|financial|fund|fixedtofloating|fixed|floating|f|group|g|healthcare|holdings|holding|h|inc|incorporated|interests|interest|in|index|income|i|junior|j|k|liability|limited|lp|llc|ltd|long|l|markets|maturity|municipal|muni|monthly|m|noncumulative|notes|no|n|of|one|or|o|portfolio|pay|partnership|partner|par|perpetual|per|perp|pfd|preference|preferred|p|q|redeemable|repstg|representing|represents|rate|r|sa|smallcap|series|shs|shares|share|short|stock|subordinated|ser|senior|s|the|three|term|to|traded|trust|two|t|ultrashort|ultra|u|value|v|warrant|weight|w|x|y|z';
Call:
$cn=strtolower(UpdateStocks::slugCompany($s["quote"]["companyName"])); // slug company
Part of Input (Last tab, Name of Company):
A 2019-01-04 AGILENT TECHNOLOGIES INC
AA 2019-01-04 ALCOA CORP
AAAU 2019-01-04 PERTH MINT PHYSICAL GOLD ETF
AABA 2019-01-04 ALTABA INC
AAC 2019-01-04 AAC HOLDINGS INC
AADR 2019-01-04 ADVISORSHARES DORSEY WRIGHT
AAL 2019-01-04 AMERICAN AIRLINES GROUP INC
AAMC 2019-01-04 ALTISOURCE ASSET MANAGEMENT
AAME 2019-01-04 ATLANTIC AMERICAN CORP
AAN 2019-01-04 AARON'S INC
AAOI 2019-01-04 APPLIED OPTOELECTRONICS INC
AAON 2019-01-04 AAON INC
AAP 2019-01-04 ADVANCE AUTO PARTS INC
AAPL 2019-01-04 APPLE INC
AAT 2019-01-04 AMERICAN ASSETS TRUST INC
AAU 2019-01-04 ALMADEN MINERALS LTD - B
AAWW 2019-01-04 ATLAS AIR WORLDWIDE HOLDINGS
AAXJ 2019-01-04 ISHARES MSCI ALL COUNTRY ASI
AAXN 2019-01-04 AXON ENTERPRISE INC
AB 2019-01-04 ALLIANCEBERNSTEIN HOLDING LP
ABAC 2019-01-04 RENMIN TIANLI GROUP INC
ABB 2019-01-04 ABB LTD-SPON ADR
ABBV 2019-01-04 ABBVIE INC
ABC 2019-01-04 AMERISOURCEBERGEN CORP
ABCB 2019-01-04 AMERIS BANCORP
ABDC 2019-01-04 ALCENTRA CAPITAL CORP
ABEO 2019-01-04 ABEONA THERAPEUTICS INC
ABEOW 2019-01-04
ABEV 2019-01-04 AMBEV SA-ADR
ABG 2019-01-04 ASBURY AUTOMOTIVE GROUP
ABIL 2019-01-04 ABILITY INC
ABIO 2019-01-04 ARCA BIOPHARMA INC
ABM 2019-01-04 ABM INDUSTRIES INC
ABMD 2019-01-04 ABIOMED INC
ABR 2019-01-04 ARBOR REALTY TRUST INC
ABR-A 2019-01-04
ABR-B 2019-01-04
ABR-C 2019-01-04
ABT 2019-01-04 ABBOTT LABORATORIES
ABTX 2019-01-04 ALLEGIANCE BANCSHARES INC
ABUS 2019-01-04 ARBUTUS BIOPHARMA CORP
AC 2019-01-04 ASSOCIATED CAPITAL GROUP - A
ACA 2019-01-04 ARCOSA INC
ACAD 2019-01-04 ACADIA PHARMACEUTICALS INC
ACB 2019-01-04 AURORA CANNABIS INC
ACBI 2019-01-04 ATLANTIC CAPITAL BANCSHARES
ACC 2019-01-04 AMERICAN CAMPUS COMMUNITIES
ACCO 2019-01-04 ACCO BRANDS CORP
ACER 2019-01-04 ACER THERAPEUTICS INC
ACES 2019-01-04 ALPS CLEAN ENERGY ETF
ACET 2019-01-04 ACETO CORP
ACGL 2019-01-04 ARCH CAPITAL GROUP LTD
ACGLO 2019-01-04
ACGLP 2019-01-04
ACH 2019-01-04 ALUMINUM CORP OF CHINA-ADR
ACHC 2019-01-04 ACADIA HEALTHCARE CO INC
ACHN 2019-01-04 ACHILLION PHARMACEUTICALS
ACHV 2019-01-04 ACHIEVE LIFE SCIENCES INC
ACIA 2019-01-04 ACACIA COMMUNICATIONS INC
ACIM 2019-01-04 SPDR MSCI ACWI IMI ETF
ACIU 2019-01-04 AC IMMUNE SA
ACIW 2019-01-04 ACI WORLDWIDE INC
ACLS 2019-01-04 AXCELIS TECHNOLOGIES INC
ACM 2019-01-04 AECOM
ACMR 2019-01-04 ACM RESEARCH INC-CLASS A
ACN 2019-01-04 ACCENTURE PLC-CL A
ACNB 2019-01-04 ACNB CORP
ACOR 2019-01-04 ACORDA THERAPEUTICS INC
ACP 2019-01-04 ABERDEEN INCOME CREDIT STRAT
ACRE 2019-01-04 ARES COMMERCIAL REAL ESTATE
ACRS 2019-01-04 ACLARIS THERAPEUTICS INC
ACRX 2019-01-04 ACELRX PHARMACEUTICALS INC
ACSG 2019-01-04 XTRACKERS MSCI ACWI EX USA E
ACSI 2019-01-04 AMERICAN CUSTOMER SATISFACTI
ACST 2019-01-04 ACASTI PHARMA INC
ACT 2019-01-04 ADVISORSHARES VICE ETF
ACTG 2019-01-04 ACACIA RESEARCH CORP
ACU 2019-01-04 ACME UNITED CORP
ACV 2019-01-04 ALLIANZGI DIVERSIFIED INCOME
ACWF 2019-01-04 ISHARES EDGE MSCI MULTIFACTO
ACWI 2019-01-04 ISHARES MSCI ACWI ETF
ACWV 2019-01-04 ISHARES EDGE MSCI MIN VOL GL
ACWX 2019-01-04 ISHARES MSCI ACWI EX US ETF
ACY 2019-01-04 AEROCENTURY CORP
ADAP 2019-01-04 ADAPTIMMUNE THERAPEUTICS-ADR
ADBE 2019-01-04 ADOBE INC
ADC 2019-01-04 AGREE REALTY CORP
ADES 2019-01-04 ADVANCED EMISSIONS SOLUTIONS
ADI 2019-01-04 ANALOG DEVICES INC
ADIL 2019-01-04 ADIAL PHARMACEUTICALS INC
ADILW 2019-01-04
ADM 2019-01-04 ARCHER-DANIELS-MIDLAND CO
ADMA 2019-01-04 ADMA BIOLOGICS INC
ADMP 2019-01-04 ADAMIS PHARMACEUTICALS CORP
ADMS 2019-01-04 ADAMAS PHARMACEUTICALS INC
ADNT 2019-01-04 ADIENT PLC
ADOM 2019-01-04 ADOMANI INC
ADP 2019-01-04 AUTOMATIC DATA PROCESSING
ADRA 2019-01-04 INVESCO BLDRS ASIA 50 ADR IN
ADRD 2019-01-04 INVESCO BLDRS DEVELOPED MARK
ADRE 2019-01-04 INVESCO BLDRS EMERGING MARKE
ADRO 2019-01-04 ADURO BIOTECH INC
ADRU 2019-01-04 INVESCO BLDRS EUROPE SELECT
ADS 2019-01-04 ALLIANCE DATA SYSTEMS CORP
ADSK 2019-01-04 AUTODESK INC
ADSW 2019-01-04 ADVANCED DISPOSAL SERVICES I
ADT 2019-01-04 ADT INC
ADTN 2019-01-04 ADTRAN INC
ADUS 2019-01-04 ADDUS HOMECARE CORP
ADVM 2019-01-04 ADVERUM BIOTECHNOLOGIES INC
ADX 2019-01-04 ADAMS DIVERSIFIED EQUITY
ADXS 2019-01-04 ADVAXIS INC
AE 2019-01-04 ADAMS RESOURCES & ENERGY INC
AEB 2019-01-04
AED 2019-01-04
AEE 2019-01-04 AMEREN CORPORATION
AEF 2019-01-04 ABERDEEN EM MRKT EQTY INC
AEG 2019-01-04 AEGON N.V.-NY REG SHR
AEGN 2019-01-04 AEGION CORP
AEH 2019-01-04
AEHR 2019-01-04 AEHR TEST SYSTEMS
AEIS 2019-01-04 ADVANCED ENERGY INDUSTRIES
AEL 2019-01-04 AMERICAN EQUITY INVT LIFE HL
AEM 2019-01-04 AGNICO EAGLE MINES LTD
AEMD 2019-01-04 AETHLON MEDICAL INC
AEO 2019-01-04 AMERICAN EAGLE OUTFITTERS
AEP 2019-01-04 AMERICAN ELECTRIC POWER
AER 2019-01-04 AERCAP HOLDINGS NV
AERI 2019-01-04 AERIE PHARMACEUTICALS INC
AES 2019-01-04 AES CORP
AETI 2019-01-04 AMERICAN ELECTRIC TECHNOLOGI
AEY 2019-01-04 ADDVANTAGE TECHNOLOGIES GRP
AEYE 2019-01-04 AUDIOEYE INC
AEZS 2019-01-04 AETERNA ZENTARIS INC
AFB 2019-01-04 ALLIANCE NATIONAL MUNI INC
AFC 2019-01-04
AFG 2019-01-04 AMERICAN FINANCIAL GROUP INC
AFGE 2019-01-04
AFGH 2019-01-04
AFH 2019-01-04 ATLAS FINANCIAL HOLDINGS INC
AFHBL 2019-01-04
AFI 2019-01-04 ARMSTRONG FLOORING INC
AFIF 2019-01-04 ANFIELD UNIVERSAL FIXED INCO
AFIN 2019-01-04 AMERICAN FINANCE TRUST INC
AFK 2019-01-04 VANECK VECTORS AFRICA INDEX
AFL 2019-01-04 AFLAC INC
AFMD 2019-01-04 AFFIMED NV
AFSI-A 2019-01-04
AFSI-B 2019-01-04
AFSI-C 2019-01-04
AFSI-D 2019-01-04
AFSI-E 2019-01-04
AFSI-F 2019-01-04
AFSS 2019-01-04
AFST 2019-01-04
AFT 2019-01-04 APOLLO SENIOR FLOATING RATE
AFTY 2019-01-04 CSOP FTSE CHINA A50 ETF
AG 2019-01-04 FIRST MAJESTIC SILVER CORP
AGCO 2019-01-04 AGCO CORP
AGD 2019-01-04 ABERDEEN GLBL DYN DIVID
AGE 2019-01-04 AGEX THERAPEUTICS INC
AGEN 2019-01-04 AGENUS INC
AGF 2019-01-04 DB AGRICULTURE LONG ETN
AGFS 2019-01-04 AGROFRESH SOLUTIONS INC
AGFSW 2019-01-04
AGG 2019-01-04 ISHARES CORE U.S. AGGREGATE
AGGE 2019-01-04 IQ ENHANCED CORE BOND US ETF
AGGP 2019-01-04 IQ ENHANCED CORE PLUS BOND U
AGGY 2019-01-04 WISDOMTREE YIELD ENHANCED US
AGI 2019-01-04 ALAMOS GOLD INC-CLASS A
AGIO 2019-01-04 AGIOS PHARMACEUTICALS INC
AGLE 2019-01-04 AEGLEA BIOTHERAPEUTICS INC
AGM 2019-01-04 FEDERAL AGRIC MTG CORP-CL C
AGM-A 2019-01-04
AGM-B 2019-01-04
AGM-C 2019-01-04
AGM.A 2019-01-04 FEDERAL AGRIC MTG CORP-CL A
AGMH 2019-01-04 AGM GROUP HOLDINGS INC
AGN 2019-01-04 ALLERGAN PLC
AGNC 2019-01-04 AGNC INVESTMENT CORP
AGNCB 2019-01-04
AGNCN 2019-01-04
AGND 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AGO 2019-01-04 ASSURED GUARANTY LTD
AGO-B 2019-01-04
AGO-E 2019-01-04
AGO-F 2019-01-04
AGQ 2019-01-04 PROSHARES ULTRA SILVER
AGR 2019-01-04 AVANGRID INC
AGRO 2019-01-04 ADECOAGRO SA
AGRX 2019-01-04 AGILE THERAPEUTICS INC
AGS 2019-01-04 PLAYAGS INC
AGT 2019-01-04 ISHARES ARGENTINA
AGTC 2019-01-04 APPLIED GENETIC TECHNOLOGIES
AGX 2019-01-04 ARGAN INC
AGYS 2019-01-04 AGILYSYS INC
AGZ 2019-01-04 ISHARES AGENCY BOND ETF
AGZD 2019-01-04 WISDOMTREE TRUST WISDOMTREE
AHC 2019-01-04 A H BELO CORP-A
AHH 2019-01-04 ARMADA HOFFLER PROPERTIES IN
AHL 2019-01-04 ASPEN INSURANCE HOLDINGS LTD
AHL-C 2019-01-04
AHL-D 2019-01-04
AHPI 2019-01-04 ALLIED HEALTHCARE PRODUCTS
AHT 2019-01-04 ASHFORD HOSPITALITY TRUST
AHT-D 2019-01-04
AHT-F 2019-01-04
AHT-G 2019-01-04
AHT-H 2019-01-04
AHT-I 2019-01-04
AI 2019-01-04 ARLINGTON ASSET INVESTMENT-A
AI-B 2019-01-04
AIA 2019-01-04 ISHARES ASIA 50 ETF
AIC 2019-01-04
AIEQ 2019-01-04 AI POWERED EQUITY ETF
AIF 2019-01-04 APOLLO TACTICAL INCOME FUND
AIG 2019-01-04 AMERICAN INTERNATIONAL GROUP
AIG+ 2019-01-04
AIHS 2019-01-04 SENMIAO TECHNOLOGY LTD
AIIQ 2019-01-04 AI POWERED INTERNATIONAL EQU
AIMC 2019-01-04 ALTRA INDUSTRIAL MOTION CORP
AIMT 2019-01-04 AIMMUNE THERAPEUTICS INC
AIN 2019-01-04 ALBANY INTL CORP-CL A
AINC 2019-01-04 ASHFORD INC
AINV 2019-01-04 APOLLO INVESTMENT CORP
AIPT 2019-01-04 PRECISION THERAPEUTICS INC
AIQ 2019-01-04 Global X Future Analytics TE
AIR 2019-01-04 AAR CORP
AIRG 2019-01-04 AIRGAIN INC
AIRI 2019-01-04 AIR INDUSTRIES GROUP
AIRR 2019-01-04 FIRST TRUST RBA AMERICAN IND
AIRT 2019-01-04 AIR T INC
AIT 2019-01-04 APPLIED INDUSTRIAL TECH INC
AIV 2019-01-04 APARTMENT INVT & MGMT CO -A
AIV-A 2019-01-04
AIW 2019-01-04
AIY 2019-01-04
AIZ 2019-01-04 ASSURANT INC
AIZP 2019-01-04
AJG 2019-01-04 ARTHUR J GALLAGHER & CO
AJRD 2019-01-04 AEROJET ROCKETDYNE HOLDINGS
AJX 2019-01-04 GREAT AJAX CORP
AJXA 2019-01-04
AKAM 2019-01-04 AKAMAI TECHNOLOGIES INC
AKAO 2019-01-04 ACHAOGEN INC
AKBA 2019-01-04 AKEBIA THERAPEUTICS INC
AKCA 2019-01-04 AKCEA THERAPEUTICS INC
AKER 2019-01-04 AKERS BIOSCIENCES INC
AKG 2019-01-04 ASANKO GOLD INC
AKO.A 2019-01-04 EMBOTELLADORA ANDINA-ADR A
AKO.B 2019-01-04 EMBOTELLADORA ANDINA-ADR B
AKP 2019-01-04 ALLIANCE CALIF MUNI INCOME
AKR 2019-01-04 ACADIA REALTY TRUST
AKRX 2019-01-04 AKORN INC
AKS 2019-01-04 AK STEEL HOLDING CORP
AKTS 2019-01-04 AKOUSTIS TECHNOLOGIES INC
AKTX 2019-01-04 AKARI THERAPEUTICS PLC-ADR
AL 2019-01-04 AIR LEASE CORP
ALAC 2019-01-04 ALBERTON ACQUISITION CORP
ALACR 2019-01-04 ALBERTON ACQUISITION CO-RTS
ALACU 2019-01-04 ALBERTON ACQUISITION CORP
ALACW 2019-01-04
ALB 2019-01-04 ALBEMARLE CORP
ALBO 2019-01-04 ALBIREO PHARMA INC
ALCO 2019-01-04 ALICO INC
ALD 2019-01-04 WISDOMTREE ASIA LOCAL DEBT
ALDR 2019-01-04 ALDER BIOPHARMACEUTICALS INC
ALDX 2019-01-04 ALDEYRA THERAPEUTICS INC
ALE 2019-01-04 ALLETE INC
ALEX 2019-01-04 ALEXANDER & BALDWIN INC
ALFA 2019-01-04 ALPHACLONE ALTERNATIVE ALPHA
ALG 2019-01-04 ALAMO GROUP INC
ALGN 2019-01-04 ALIGN TECHNOLOGY INC
ALGR 2019-01-04 ALLEGRO MERGER CORP
ALGRR 2019-01-04 ALLEGRO MERGER CORP-RTS
ALGRU 2019-01-04 ALLEGRO MERGER CORP
ALGRW 2019-01-04
ALGT 2019-01-04 ALLEGIANT TRAVEL CO
ALIM 2019-01-04 ALIMERA SCIENCES INC
ALJJ 2019-01-04 ALJ REGIONAL HOLDINGS INC
ALK 2019-01-04 ALASKA AIR GROUP INC
ALKS 2019-01-04 ALKERMES PLC
ALL 2019-01-04 ALLSTATE CORP
Desired Output Example (for URLs):
agilent-technologies
php7.1
performance beginner php strings regex
performance beginner php strings regex
edited Mar 14 at 16:02
yuri
3,66921034
3,66921034
asked Mar 14 at 4:21
EmmaEmma
183112
183112
$begingroup$
You wrote most of it, i.e. this is not your code? You also state: "desired output", does it not produce the desired output?
$endgroup$
– yuri
Mar 14 at 16:00
add a comment |
$begingroup$
You wrote most of it, i.e. this is not your code? You also state: "desired output", does it not produce the desired output?
$endgroup$
– yuri
Mar 14 at 16:00
$begingroup$
You wrote most of it, i.e. this is not your code? You also state: "desired output", does it not produce the desired output?
$endgroup$
– yuri
Mar 14 at 16:00
$begingroup$
You wrote most of it, i.e. this is not your code? You also state: "desired output", does it not produce the desired output?
$endgroup$
– yuri
Mar 14 at 16:00
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
I would clean it up a bit:
public static function slugCompany($company){
$replace = [
'/[^da-zs]/i' => '', //remove punctuation I guess
'/b('.self::COMPANY_STOPWORDS.')b/i' => '', //remove these companies
'/^s+|s+$/' => '', //trim
'/s+/' => '-' //replace space with -
];
return preg_replace(array_keys($replace), $replace, strtolower($company));
}
I cleaned up all these local variables, got rid of a few repetitive calls. The array_keys
and array structure are mainly for readability reasons and ease of use. For example now you can easly add replacements if you need to because they use a common array for the replacements.
Sandbox
Its more of a readability fix as it's hard to know all the input you may have so I have to trust that you covered all the edge cases.
Your code
Hope it helps.
$endgroup$
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
1
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f215394%2fstring-replace-for-8000-company-names-iteration-with-php-slug%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I would clean it up a bit:
public static function slugCompany($company){
$replace = [
'/[^da-zs]/i' => '', //remove punctuation I guess
'/b('.self::COMPANY_STOPWORDS.')b/i' => '', //remove these companies
'/^s+|s+$/' => '', //trim
'/s+/' => '-' //replace space with -
];
return preg_replace(array_keys($replace), $replace, strtolower($company));
}
I cleaned up all these local variables, got rid of a few repetitive calls. The array_keys
and array structure are mainly for readability reasons and ease of use. For example now you can easly add replacements if you need to because they use a common array for the replacements.
Sandbox
Its more of a readability fix as it's hard to know all the input you may have so I have to trust that you covered all the edge cases.
Your code
Hope it helps.
$endgroup$
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
1
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
add a comment |
$begingroup$
I would clean it up a bit:
public static function slugCompany($company){
$replace = [
'/[^da-zs]/i' => '', //remove punctuation I guess
'/b('.self::COMPANY_STOPWORDS.')b/i' => '', //remove these companies
'/^s+|s+$/' => '', //trim
'/s+/' => '-' //replace space with -
];
return preg_replace(array_keys($replace), $replace, strtolower($company));
}
I cleaned up all these local variables, got rid of a few repetitive calls. The array_keys
and array structure are mainly for readability reasons and ease of use. For example now you can easly add replacements if you need to because they use a common array for the replacements.
Sandbox
Its more of a readability fix as it's hard to know all the input you may have so I have to trust that you covered all the edge cases.
Your code
Hope it helps.
$endgroup$
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
1
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
add a comment |
$begingroup$
I would clean it up a bit:
public static function slugCompany($company){
$replace = [
'/[^da-zs]/i' => '', //remove punctuation I guess
'/b('.self::COMPANY_STOPWORDS.')b/i' => '', //remove these companies
'/^s+|s+$/' => '', //trim
'/s+/' => '-' //replace space with -
];
return preg_replace(array_keys($replace), $replace, strtolower($company));
}
I cleaned up all these local variables, got rid of a few repetitive calls. The array_keys
and array structure are mainly for readability reasons and ease of use. For example now you can easly add replacements if you need to because they use a common array for the replacements.
Sandbox
Its more of a readability fix as it's hard to know all the input you may have so I have to trust that you covered all the edge cases.
Your code
Hope it helps.
$endgroup$
I would clean it up a bit:
public static function slugCompany($company){
$replace = [
'/[^da-zs]/i' => '', //remove punctuation I guess
'/b('.self::COMPANY_STOPWORDS.')b/i' => '', //remove these companies
'/^s+|s+$/' => '', //trim
'/s+/' => '-' //replace space with -
];
return preg_replace(array_keys($replace), $replace, strtolower($company));
}
I cleaned up all these local variables, got rid of a few repetitive calls. The array_keys
and array structure are mainly for readability reasons and ease of use. For example now you can easly add replacements if you need to because they use a common array for the replacements.
Sandbox
Its more of a readability fix as it's hard to know all the input you may have so I have to trust that you covered all the edge cases.
Your code
Hope it helps.
edited Mar 15 at 10:18
answered Mar 15 at 9:53
ArtisticPhoenixArtisticPhoenix
33117
33117
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
1
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
add a comment |
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
1
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
$begingroup$
Hi ArtisticPhoenix, This looks so great, and is certainly helpful! Will do so! Thanks so much!
$endgroup$
– Emma
Mar 15 at 13:42
1
1
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
$begingroup$
Sure all I did is re-arange some stuff. I usually write my own code 3 or 4 times before I am happy with it. Once to get it working, once to make it readable and once to improve the performance. Don't be afraid to say this is too much I need to simplify it. Its a process like writing an English paper.
$endgroup$
– ArtisticPhoenix
Mar 15 at 15:23
add a comment |
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f215394%2fstring-replace-for-8000-company-names-iteration-with-php-slug%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
You wrote most of it, i.e. this is not your code? You also state: "desired output", does it not produce the desired output?
$endgroup$
– yuri
Mar 14 at 16:00