3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //Returns the nearest craigslist hotspot. //nearjump.php?lat&lng //Returns:prefix#center_lat#center_lng //Hotspot array: $items = array( '0'=>array('sfbay','37.7749295','-122.4194155'), '1'=>array('abilene','32.4487364','-99.7331439'), '2'=>array('akroncanton','41.2020435','-81.4278984'), '3'=>array('albanyga','31.5785074','-84.155741'), '4'=>array('albany','42.6525793','-73.7562317'), '5'=>array('albuquerque','35.110703','-106.609991'), '6'=>array('altoona','40.3555683','-78.5164333'), '7'=>array('amarillo','35.2219971','-101.8312969'), '8'=>array('ames','42.02335','-93.625622'), '9'=>array('anchorage','61.3828294','-150.2507886'), '10'=>array('annarbor','42.2808256','-83.7430378'), '11'=>array('annapolis','38.9784453','-76.4921829'), '12'=>array('appleton','44.2619309','-88.4153847'), '13'=>array('asheville','35.5950581','-82.5514869'), '14'=>array('ashtabula','41.8650534','-80.7898089'), '15'=>array('athensga','33.95','-83.3833333'), '16'=>array('athensohio','39.3292396','-82.1012554'), '17'=>array('atlanta','33.7489954','-84.3879824'), '18'=>array('auburn','47.3073228','-122.2284532'), '19'=>array('augusta','33.4734978','-82.0105148'), '20'=>array('austin','30.267153','-97.7430608'), '21'=>array('bakersfield','35.3732921','-119.0187125'), '22'=>array('baltimore','39.2903848','-76.6121893'), '23'=>array('batonrouge','30.4582829','-91.1403196'), '24'=>array('battlecreek','42.3211522','-85.1797142'), '25'=>array('beaumont','29.9843274','-94.0607822'), '26'=>array('bellingham','48.7595529','-122.4882249'), '27'=>array('bemidji','47.4736111','-94.8802778'), '28'=>array('bend','44.0581728','-121.3153096'), '29'=>array('billings','45.7832856','-108.5006904'), '30'=>array('binghamton','42.0986867','-75.9179738'), '31'=>array('bham','33.5206608','-86.80249'), '32'=>array('bismarck','46.8083268','-100.7837392'), '33'=>array('bloomington','39.165325','-86.5263857'), '34'=>array('bn','40.4842027','-88.9936873'), '35'=>array('boise','43.6187102','-116.2146068'), '36'=>array('boone','36.216795','-81.6745517'), '37'=>array('boston','42.3584308','-71.0597732'), '38'=>array('boulder','40.0149856','-105.2705456'), '39'=>array('bgky','36.9685219','-86.4808043'), '40'=>array('bozeman','45.6834599','-111.050499'), '41'=>array('brainerd','46.35297','-94.199982'), '42'=>array('brownsville','25.9017472','-97.4974838'), '43'=>array('brunswick','31.1499528','-81.4914894'), '44'=>array('buffalo','42.8864468','-78.8783689'), '45'=>array('butte','46.0038232','-112.5347776'), '46'=>array('capecod','41.648513','-70.295864'), '47'=>array('catskills','42.2197051','-74.5025275'), '48'=>array('cedarrapids','41.9778795','-91.6656232'), '49'=>array('cnj','39.829728','-74.9789595'), '50'=>array('cenla','30.554281','-91.0368766'), '51'=>array('centralmich','42.6198683','-83.9163781'), '52'=>array('chambana','40.1105875','-88.2072697'), '53'=>array('charleston','32.7765656','-79.9309216'), '54'=>array('charlestonwv','38.3498195','-81.6326234'), '55'=>array('charlotte','35.2270869','-80.8431267'), '56'=>array('charlottesville','38.0293059','-78.4766781'), '57'=>array('chattanooga','35.0456297','-85.3096801'), '58'=>array('chautauqua','42.209774','-79.4668445'), '59'=>array('chicago','41.8781136','-87.6297982'), '60'=>array('chico','39.7284944','-121.8374777'), '61'=>array('chillicothe','39.3331197','-82.9824019'), '62'=>array('cincinnati','39.1031182','-84.5120196'), '63'=>array('clarksville','36.5297706','-87.3594528'), '64'=>array('cleveland','41.4994954','-81.6954088'), '65'=>array('clovis','34.2596102','-103.2388376'), '66'=>array('collegestation','30.627977','-96.3344068'), '67'=>array('cosprings','38.8338816','-104.8213634'), '68'=>array('columbiamo','39.0468547','-92.3813621'), '69'=>array('columbia','34.0007104','-81.0348144'), '70'=>array('columbusga','32.4609764','-84.9877094'), '71'=>array('columbus','39.9611755','-82.9987942'), '72'=>array('cookeville','36.162839','-85.5016423'), '73'=>array('corpuschristi','27.8005828','-97.396381'), '74'=>array('corvallis','44.6281686','-123.3873877'), '75'=>array('chambersburg','39.8110168','-78.6341996'), '76'=>array('dallas','32.7554883','-97.3307658'), '77'=>array('danville','37.8215929','-121.9999606'), '78'=>array('dayton','39.7699401','-84.151428'), '79'=>array('daytona','29.2108147','-81.0228331'), '80'=>array('decatur','39.8403147','-88.9548001'), '81'=>array('nacogdoches','31.3337041','-94.7299021'), '82'=>array('delrio','28.7916315','-100.518767'), '83'=>array('delaware','38.9108325','-75.5276699'), '84'=>array('denver','39.737567','-104.9847179'), '85'=>array('desmoines','41.6005448','-93.6091064'), '86'=>array('detroit','42.2161722','-83.3553842'), '87'=>array('dothan','31.2232313','-85.3904888'), '88'=>array('dubuque','42.5005583','-90.6645718'), '89'=>array('duluth','46.7866719','-92.1004852'), '90'=>array('eastidaho','44.0682019','-114.7420408'), '91'=>array('eastoregon','43.8041334','-120.5542012'), '92'=>array('eastco','39.3336248','-76.4306993'), '93'=>array('newlondon','33.9855262','-118.4641826'), '94'=>array('eastnc','33.9370119','-78.2177077'), '95'=>array('eastky','37.5164758','-82.8067126'), '96'=>array('montana','27.5484142','-99.4842334'), '97'=>array('martinsburg','39.487248','-77.805435'), '98'=>array('easternshore','38.5001155','-75.499644'), '99'=>array('eauclaire','44.811349','-91.4984941'), '100'=>array('elpaso','31.7699559','-106.4968055'), '101'=>array('elko','40.8324211','-115.7631232'), '102'=>array('elmira','42.1362071','-76.7798172'), '103'=>array('erie','42.1292241','-80.085059'), '104'=>array('eugene','44.0520691','-123.0867536'), '105'=>array('evansville','37.9715592','-87.5710898'), '106'=>array('fairbanks','64.8377778','-147.7163889'), '107'=>array('fargo','46.8771863','-96.7898034'), '108'=>array('farmington','36.7280583','-108.2186856'), '109'=>array('fayar','36.0625795','-94.1574263'), '110'=>array('fayetteville','35.0526641','-78.8783585'), '111'=>array('fingerlakes','42.8334002','-76.9999669'), '112'=>array('flagstaff','34.8262376','-111.7776875'), '113'=>array('flint','43.0125274','-83.6874562'), '114'=>array('shoals','34.8148561','-87.6426644'), '115'=>array('florencesc','34.1954331','-79.7625625'), '116'=>array('keys','24.5557359','-81.7826537'), '117'=>array('fortcollins','40.5852602','-105.084423'), '118'=>array('fortdodge','42.4974694','-94.1680158'), '119'=>array('fortsmith','35.3859242','-94.3985475'), '120'=>array('fortwayne','41.079273','-85.1393513'), '121'=>array('frederick','39.4142688','-77.4105409'), '122'=>array('fredericksburg','38.3031837','-77.4605399'), '123'=>array('fresno','36.7468422','-119.7725868'), '124'=>array('fortmyers','26.640628','-81.8723084'), '125'=>array('gadsden','33.6229395','-85.8016728'), '126'=>array('gainesville','29.6516344','-82.3248262'), '127'=>array('galveston','29.3013479','-94.7976958'), '128'=>array('glensfalls','43.3095164','-73.6440058'), '129'=>array('goldcountry','16.4171818','120.575146'), '130'=>array('grandforks','47.9252568','-97.0328547'), '131'=>array('grandisland','40.9263957','-98.3420118'), '132'=>array('grandrapids','42.9633599','-85.6680863'), '133'=>array('greatfalls','47.4941836','-111.2833449'), '134'=>array('greenbay','44.519159','-88.019826'), '135'=>array('greensboro','36.0726354','-79.7919754'), '136'=>array('greenville','42.4153596','-74.0220769'), '137'=>array('gulfport','30.41338','-89.072958'), '138'=>array('norfolk','36.9641586','-76.3521514'), '139'=>array('hanford','36.3274502','-119.6456844'), '140'=>array('harrisburg','40.2737002','-76.8844179'), '141'=>array('harrisonburg','38.4495688','-78.8689155'), '142'=>array('hartford','41.7637111','-72.6850932'), '143'=>array('hattiesburg','31.3271189','-89.2903392'), '144'=>array('honolulu','19.8967662','-155.5827818'), '145'=>array('cfl','27.3050135','-81.3666804'), '146'=>array('helena','46.5958056','-112.0270306'), '147'=>array('hickory','35.865058','-81.4928067'), '148'=>array('rockies','39.7308872','-104.9342264'), '149'=>array('hiltonhead','32.216316','-80.752608'), '150'=>array('holland','52.132633','5.291266'), '151'=>array('houma','29.5957696','-90.7195348'), '152'=>array('houston','29.7601927','-95.3693896'), '153'=>array('hudsonvalley','41.844399','-74.074285'), '154'=>array('humboldt','40.7450055','-123.8695086'), '155'=>array('huntington','40.9435588','-82.3017728'), '156'=>array('huntsville','34.72849','-86.6611083'), '157'=>array('imperial','33.0113694','-115.4733554'), '158'=>array('indianapolis','39.768403','-86.158068'), '159'=>array('inlandempire','34.1083449','-117.2897652'), '160'=>array('iowacity','41.6611277','-91.5301683'), '161'=>array('ithaca','42.4439614','-76.5018807'), '162'=>array('jxn','42.245869','-84.4013462'), '163'=>array('jackson','32.2987573','-90.1848103'), '164'=>array('jacksontn','35.6145169','-88.8139469'), '165'=>array('jacksonville','30.3321838','-81.655651'), '166'=>array('onslow','34.7540524','-77.4302414'), '167'=>array('janesville','42.6827885','-89.0187222'), '168'=>array('jerseyshore','41.2020171','-77.2644152'), '169'=>array('jonesboro','35.8422967','-90.704279'), '170'=>array('joplin','37.0842271','-94.513281'), '171'=>array('kalamazoo','42.2917069','-85.5872286'), '172'=>array('kalispell','48.200531','-114.315102'), '173'=>array('kansascity','39.0997265','-94.5785667'), '174'=>array('kenai','59.8785222','-150.3952272'), '175'=>array('kpr','46.1093145','-119.1994766'), '176'=>array('racine','42.5847425','-87.8211854'), '177'=>array('killeen','31.1171194','-97.7277959'), '178'=>array('kirksville','40.1947539','-92.5832496'), '179'=>array('klamath','42.224867','-121.7816704'), '180'=>array('knoxville','35.9606384','-83.9207392'), '181'=>array('kokomo','40.486427','-86.1336033'), '182'=>array('lacrosse','43.8013556','-91.2395807'), '183'=>array('lasalle','40.3488703','-104.7019102'), '184'=>array('lafayette','30.2240897','-92.0198427'), '185'=>array('tippecanoe','40.2753487','-81.7509601'), '186'=>array('lakecharles','30.2265949','-93.2173758'), '187'=>array('loz','38.1380003','-92.8103551'), '188'=>array('lakeland','28.0394654','-81.9498042'), '189'=>array('lancaster','40.0378755','-76.3055144'), '190'=>array('lansing','42.732535','-84.5555347'), '191'=>array('laredo','27.5305671','-99.4803241'), '192'=>array('lascruces','32.3199396','-106.7636538'), '193'=>array('lasvegas','36.1699412','-115.1398296'), '194'=>array('lawrence','38.9716689','-95.2352501'), '195'=>array('lawton','34.6035669','-98.3959291'), '196'=>array('allentown','40.6645737','-75.5113752'), '197'=>array('lewiston','46.4037998','-117.024169'), '198'=>array('lexington','38.0405837','-84.5037164'), '199'=>array('limaohio','40.7543375','-84.0831903'), '200'=>array('lincoln','40.806862','-96.681679') ) //Sorting Algorithm function distance($lat1, $lon1, $lat2, $lon2) { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; return $miles; } //Main Code $ref = array(0,0); $distances = array_map(function($item) use($ref) { $a = array_slice($item, -2); return distance($a[0],$a[1],$ref[0],$ref[1]); }, $items); asort($distances); echo $items[key($distances)][0]."#".$items[key($distances)][1]."#".$items[key($distances)][2]; ?>
Output for 5.4.0 - 5.4.29
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /in/LPkUT on line 213
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_FUNCTION in /in/LPkUT on line 213
Process exited with code 255.