PATTERN: Input: http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-6515811997029694&output=html&h=250&slotname=2638665468&w=300&lmt=1295223106&flash=10.1.102.64&url=http%3A%2F%2Fwww.prostatecancerguide.net%2FGleason-scale.php&dt=1295223106729&shv=r20101117&jsv=r20110114&saldr=1&prev_slotnames=3369741726%2C5211073747%2C8537021660&correlator=1295223106229&frm=0&adk=3654972279&ga_vid=844010415.1295223106&ga_sid=1295223106&ga_hid=82990496&ga_fc=0&u_tz=-300&u_his=3&u_java=1&u_h=800&u_w=1280&u_ah=770&u_aw=1280&u_cd=32&u_nplug=0&u_nmime=0&biw=1259&bih=526&eid=30143103&ref=http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dgleason%2Bscale%26rls%3Dcom.microsoft%3Aen-us%26ie%3DUTF-8%26oe%3DUTF-8%26startIndex%3D%26startPage%3D1%3B&fu=0&ifi=4&dtd=31&xpc=zfdAdXSut7&p=http%3A//www.prostatecancerguide.netthe Function should RETURN: http://googleads.g.doubleclick.net/pagead/ads?....url=www.prostatecancerguide.net....&ref=...gleason... Obviously, it will return all the readable parts of the url and omit the garbages.. Thanks guys.
$tok = strtok($webAddress, "1234567890%&=q"); $str=''; $flag_qm=0; while ($tok !== false) { echo "Word=$tok<br />"; if($flag_qm==0){ $exp = explode('?',$tok); echo "Explode=$exp[0]?<br />"; $str=$str . $exp[0] . '?'; $flag_qm=1; } $exp = explode('F',$tok); if(explode('F',$tok)) { echo "<br />Yes"; } else { echo "<br />No"; } echo "<br />Explode= $exp[1]<br />"; if(exp) $str=$str.$exp[1] . '.'; $tok = strtok("1234567890%&=/q"); }