[PHP] curl ,response headers and gzip encoding
hi i am trying to build a proxy server for opera's turbo mod ? error_reporting(0); $domain='http:// '.@substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME'])+1); $data=$_SERVER['REQUEST_METHOD'].' '.$domain;$data=$data.' HTTP/1.1'; $domainadi=@parse_url($domain) or die('Hata Kod : 4');$domainadi=$domainadi['host']; if(empty($domain)) { die('Hata Kod : 4'); } foreach (getallheaders() as $name = $value) { $data.= \n$name: $value; } $data=str_replace('Host: w.com','Host: '.$domainadi,$data); $data.=\r\n\r\n; if($_SERVER['REQUEST_METHOD']=='POST') { $data.=@file_get_contents('php://input'); } #echo $domain;exit; #echo $data;exit; $ch = curl_init($domain); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if($_SERVER['REQUEST_METHOD']=='POST') { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, @file_get_contents('php://input')); } $header = array(); foreach(getallheaders() as $key = $value) { if(strtolower($key)!='host') { $header[] = $key . ':' . $value; } } curl_setopt($ch , CURLOPT_HTTPHEADER , $header); $donen=@curl_exec($ch); #header('Content-Encoding: gzip'); if(curl_getinfo($ch,CURLINFO_HTTP_CODE)=='0') die('Hata Kod:36'); @list($reshead, $body) = @explode(\r\n\r\n, $donen, 2) or die('Hata Kod :37'); $info = curl_getinfo($ch); $reshead = substr($donen, 0, $info['header_size']); $body = substr($donen, $info['header_size']); $headerlar=explode(\n,$reshead); for($i=0;$icount($headerlar);$i++) { header(trim($headerlar[$i])); } header('X-Opera-Host: v07-16:12419');header('X-Opera-Info: ID=2');header('X-OA: 8ebe63c71408d41bfa10d4fef52ea7bb961b2d22cf6cb823d1845f2be63e1950'); echo $body; curl_close($ch); ? it returns the gzip content as damaged may be for split the headers and body , , when i take curl_setopt($ch, CURLOPT_HEADER, 0); to curl_setopt($ch, CURLOPT_HEADER, 1); header('Content-Encoding: gzip'); uncomment this line hide these lines /* if(curl_getinfo($ch,CURLINFO_HTTP_CODE)=='0') die('Hata Kod:36'); @list($reshead, $body) = @explode(\r\n\r\n, $donen, 2) or die('Hata Kod :37'); $info = curl_getinfo($ch); $reshead = substr($donen, 0, $info['header_size']); $body = substr($donen, $info['header_size']); $headerlar=explode(\n,$reshead); for($i=0;$icount($headerlar);$i++) { header(trim($headerlar[$i])); } */ and return the original content echo $donen; curl_close($ch); it works nice, but i cant forward the headers to client :( and not sure why the original scripts returns the gzip content as damaged :/
Re: [PHP] array_unique by id multi-dimensional array
let me explain again this is my array Array ( [0] = Array ( [likes] = 137846 [name] = blabla [access_token] = AAABZBD [id] = 157644197612598 [link] = http://www.facebook.com/blabla ) [1] = Array ( [likes] = 137698 [name] = blabla [access_token] = AAAnnL [id] = 157644197612598 [link] = http://www.facebook.com/blabla ) [2] = Array ( [likes] = 134391 [name] = sieaq [access_token] = AAA04 [id] = 163744743683729 [link] = http://www.facebook.com/zart ) [3] = Array ( [name] = defolaq [access_token] = AAAZD [id] = 139820007610 [link] = http://www.facebook.com/apps/application.php?id=239820007640 [likes] = 0 ) [4] = Array ( [name] = falan [access_token] = AAW4NNGAZDZD [id] = 374971333999 [link] = http://www.facebook.com/apps/application.php?id=37495199 [likes] = 0 ) [5] = Array ( [name] = filan [access_token] = AAABZCTCw [id] = 237184173662497 [link] = http://www.facebook.com/pages/filan/237184173662497 [likes] = 0 ) [6] = Array ( [name] = bigit [access_token] = Jj77twGFvS8YyB [id] = 10497735291210 [link] = http://www.facebook.com/pages/bigit/10497735291210 [likes] = 0 ) ) but as you see there are 2 sub array with [id] = 157644197612598 i want to delete sub arrays repeated with same id.? 2011/10/28 tamouse mailing lists tamouse.li...@gmail.com On Thu, Oct 27, 2011 at 10:31 AM, Tontonq Tontonq root...@gmail.com wrote: i have an array like [0] = Array ( [likes] = 113091 [name] = blabla [access_token] = AAABZCTx [id] = 188206217874932 ) [1] = Array ( [likes] = 113091 [name] = blabla [access_token] = AAABZCTz [id] = 188206217874932 ) i want to filter the array by [id] sub value? Not quite sure what you mean by filter in this case, but the function that pops to mind is http://www.php.net/manual/en/function.array-filter.php, which applies a callback function to each member of the array where you can determine if it should be included in the filtered list by returning true.
Re: [PHP] array_unique by id multi-dimensional array
thanks it works 2011/10/28 sivaji j.g sivaji2...@gmail.com On Fri, Oct 28, 2011 at 1:22 PM, Tontonq Tontonq root...@gmail.comwrote: let me explain again this is my array Array ( [0] = Array ( [likes] = 137846 [name] = blabla [access_token] = AAABZBD [id] = 157644197612598 [link] = http://www.facebook.com/blabla ) [1] = Array ( [likes] = 137698 [name] = blabla [access_token] = AAAnnL [id] = 157644197612598 [link] = http://www.facebook.com/blabla ) [2] = Array ( [likes] = 134391 [name] = sieaq [access_token] = AAA04 [id] = 163744743683729 [link] = http://www.facebook.com/zart ) [3] = Array ( [name] = defolaq [access_token] = AAAZD [id] = 139820007610 [link] = http://www.facebook.com/apps/application.php?id=239820007640 [likes] = 0 ) [4] = Array ( [name] = falan [access_token] = AAW4NNGAZDZD [id] = 374971333999 [link] = http://www.facebook.com/apps/application.php?id=37495199 [likes] = 0 ) [5] = Array ( [name] = filan [access_token] = AAABZCTCw [id] = 237184173662497 [link] = http://www.facebook.com/pages/filan/237184173662497 [likes] = 0 ) [6] = Array ( [name] = bigit [access_token] = Jj77twGFvS8YyB [id] = 10497735291210 [link] = http://www.facebook.com/pages/bigit/10497735291210 [likes] = 0 ) ) but as you see there are 2 sub array with [id] = 157644197612598 i want to delete sub arrays repeated with same id.? If my understanding is right, a simple foreach loop and unset() will do this. Below is the untested version of snippet I would use to remove the duplicate sub arrays, $id = array(); foreach ($items as $key = $item) { if (in_array($item['id'], $id)) { unset($items[$key]); } else { $id[] = $item['id']; } } -- Sivaji http://sivaji.drupalgardens.com @sivaji_ganesh https://twitter.com/#%21/sivaji_ganesh in twitter sivaji2...@gmail.com Gtalk / Skype: sivaji2009
[PHP] array_unique by id multi-dimensional array
i have an array like [0] = Array ( [likes] = 113091 [name] = blabla [access_token] = AAABZCTx [id] = 188206217874932 ) [1] = Array ( [likes] = 113091 [name] = blabla [access_token] = AAABZCTz [id] = 188206217874932 ) i want to filter the array by [id] sub value?
[PHP] memory overflow :/
hi i can't see anything wrong that will cause memory problem but parsing 1gb memory limit doesn't come enough for just parsing a 50 kb file but when i try to parse another file that is 24 kb 24 mb becomes enough memory here is the script http://pastebin.com/H9mG7ucU if you go to rss.php?id=175069119656titlebaslik=1 no problem when you try to parse rss.php?id=102741716484127titlebaslik=1 Allowed memory size of 25165824 bytes exhausted (tried to allocate 90564532 bytes) Just tried to increase with ini_set('memory_limit','2048M'); still same error Allowed memory size of -2147483648 bytes exhausted (tried to allocate 2137883596 bytes) in rss.php on line 24 any idea ?
[PHP] imap_search ?
hi ! it works if there is / are emails in the box before script run (i use cli not web based) but after it works 1 time it doesnt work again it enters to infinite loop , at that line while(!$emails) { $emails = imap_search($inbox,'ALL'); echo email yok\n; print_r($emails); } imap_search($inbox,'ALL'); it doesn't try to research emails in $inbox, doesn't it stay as connected or it's just for 1 time use :S ? should i reuse imap_open everytime when i need to use imap_search ? $inbox = imap_open($hostname,$usernamex,$password) or die('Cannot connect to domain:' . imap_last_error()); function onayla() { global $inbox; $emails = imap_search($inbox,'ALL'); while(!$emails) { $emails = imap_search($inbox,'ALL'); echo email yok\n; print_r($emails); } echo \nyeaah; print_r($emails); if($emails) { rsort($emails); echo Number of email:.imap_num_msg($inbox); foreach($emails as $email_number) { $overview = imap_fetch_overview($inbox,$email_number,0); if(stristr($overview[0]-subject,Test)) { $message = imap_fetchbody($inbox,$email_number,1); echo $message\n\r; //$link=arasi('activate:','-- The',$message); //echo \n\r.$link; #fwrite(fopen(deneme.txt,w),file_get_contents($link)); //imap_delete($inbox,'1:*'); //imap_expunge($inbox); } } } imap_delete($inbox,'1:*'); imap_expunge($inbox); }
[PHP] extract price by preg_match_all
example data: div class=picboxfooter span class=newpricespan class=productOldPriceold price 829,00 euro;/spanbr /your price 58,90 euro; */span /div another : span class=newprice 9,90 euro; */span i want to extract 829,.00 58,90 from first source , 9,90 from the second i tried many way like preg_match_all('/span class=newprice(\$[0-9,]+(\.[0-9]{2})?)\/span/',$data,$prices); it doesn't work
[PHP] curl rtmp
does cUrl supports rtmp protocol? if so is there any example? do we need enable different library? so if not can we save rtmp by curl? if not is there any other rtmp downloader that u know ?
[PHP] range header in curl?
hi im downloading files from h0tf1le as a premium user by curl i want to do something like streaming i want it resend to user what it got from server i couldnt find any resource about curl and streaming the executed source so i did by the Range header but sometimes i see files are corrupted i check the logs GET http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6 Host: s137.hotfile.com Pragma: no-cache Accept: */* Connection: Keep-Alive Range: bytes=1-2 i only get 1 byte for learn length Content-Disposition: attachment; filename=pimp.rar Content-Transfer-Encoding: binary Content-Range: bytes 1-2/5781810 i see the range request:Range: bytes=0-2097152 response: Content-Disposition: attachment; filename=pimp.rar Content-Transfer-Encoding: binary Content-Range: bytes 0-2097152/5781810 Connection: close request:Range: bytes=2097152-4194304 response: Content-Disposition: attachment; filename=pimp.rar Content-Transfer-Encoding: binary Content-Range: bytes 2097152-4194304/5781810 Connection: close request:Range: bytes=4194304-5781810 Content-Disposition: attachment; filename=pimp.rar Content-Transfer-Encoding: binary Content-Range: bytes 4194304-5781810/5781810 Connection: close i can not see any error do you? and this is a part of it $kackb=arasi('Content-Range: bytes 1-2/',' ',$cikti); $bytes=(int)$kackb; $infocuk=curl_getinfo($ch); $sabiturl=$infocuk[url]; curl_close($ch); $sinir*=1024; $kackez=$bytes/$sinir; for($i=0;$i=$kackez;$i++) { $bsinir=$i*$sinir; $ssinir+=$sinir; if($bytes$ssinir) { $ssinir=$bytes; } $header = array(Range: bytes=$bsinir-$ssinir); $ch = curl_init(); curl_setopt($ch , CURLOPT_URL, $sabiturl); curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6'); curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt'); curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt'); curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt'); if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); } curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header ); curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1); $cikti = curl_exec($ch); echo $cikti; }
[PHP] extract an image's elements by gd
Hi! as first i want you look at this image http://i56.tinypic.com/2zic001.png i can read all pixels , make picture black and white,add length of black pixel's to array like (from 300x 20y to 320x to 20y). I can dump coordinates blue square as easily but i cant say this for yellow ellipse. So there are 2 questions How can i export an image's a part that i know x,y coordinates and save it as image All of you should know mspaint's free-form select,for able to export yellow ellipse i will need something like that so how can i export an image's a part like at mspaint's free-form select function are these possible with gd library?
[PHP] a quick question about array keys
a quick question lets say i have an array like that Array ( [300] = 300 [301] = 301 [302] = 302 [303] = 303 [304] = 304 [305] = 305 [306] = 306 [307] = 307 [308] = 308 ... how can i change keys to 0,1,2,3,.. by faster way (it should like that) Array ( [0] = 300 [1] = 301 [2] = 302 [3] = 303
Re: [PHP] a quick question about array keys
Ty four your all replies i got 9 replies less than 10 minutes :) than can u answer this too my array is like that for now Array ( [300] = 300 [301] = 301 [302] = 302 [303] = 303 [304] = 304 [305] = 305 [306] = 306 [307] = 307 [308] = 308 [309] = 309 [310] = 310 [311] = 311 [312] = 312 [313] = 313 [314] = 314 [165] = 165 [166] = 166 [167] = 167 [168] = 168 [169] = 169 [170] = 170 [171] = 171 [172] = 172 [173] = 173 [201] = 201 [202] = 202 [203] = 203 [204] = 204 [205] = 205 [206] = 206 [207] = 207 [208] = 208 [209] = 209 [210] = 210 [211] = 211 [212] = 212 [213] = 213 [214] = 214 [215] = 215 [315] = 315 how can i make an array that will store values like Array ( [0] = 300-314 [1] = 165-173 ) i hope if u did understand me :D 2010/8/31 la...@garfieldtech.com la...@garfieldtech.com The fastest way is going to be array_values(): http://www.php.net/array_values --Larry Garfield On 8/31/10 10:43 AM, Tontonq Tontonq wrote: a quick question lets say i have an array like that Array ( [300] = 300 [301] = 301 [302] = 302 [303] = 303 [304] = 304 [305] = 305 [306] = 306 [307] = 307 [308] = 308 ... how can i change keys to 0,1,2,3,.. by faster way (it should like that) Array ( [0] = 300 [1] = 301 [2] = 302 [3] = 303 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a quick question about array keys
i think its my mistake it will begin from first value of array it will continue until if its more big than +2 and it 2010/8/31 Ashley Sheridan a...@ashleysheridan.co.uk On Tue, 2010-08-31 at 19:06 +0300, Tontonq Tontonq wrote: Ty four your all replies i got 9 replies less than 10 minutes :) than can u answer this too my array is like that for now Array ( [300] = 300 [301] = 301 [302] = 302 [303] = 303 [304] = 304 [305] = 305 [306] = 306 [307] = 307 [308] = 308 [309] = 309 [310] = 310 [311] = 311 [312] = 312 [313] = 313 [314] = 314 [165] = 165 [166] = 166 [167] = 167 [168] = 168 [169] = 169 [170] = 170 [171] = 171 [172] = 172 [173] = 173 [201] = 201 [202] = 202 [203] = 203 [204] = 204 [205] = 205 [206] = 206 [207] = 207 [208] = 208 [209] = 209 [210] = 210 [211] = 211 [212] = 212 [213] = 213 [214] = 214 [215] = 215 [315] = 315 how can i make an array that will store values like Array ( [0] = 300-314 [1] = 165-173 ) i hope if u did understand me :D 2010/8/31 la...@garfieldtech.com la...@garfieldtech.com The fastest way is going to be array_values(): http://www.php.net/array_values --Larry Garfield On 8/31/10 10:43 AM, Tontonq Tontonq wrote: a quick question lets say i have an array like that Array ( [300] = 300 [301] = 301 [302] = 302 [303] = 303 [304] = 304 [305] = 305 [306] = 306 [307] = 307 [308] = 308 ... how can i change keys to 0,1,2,3,.. by faster way (it should like that) Array ( [0] = 300 [1] = 301 [2] = 302 [3] = 303 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oops, I slightly mis-read the question there in my last post. I'm not actually sure what it is you *are* after though. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] multi thread work?
Hi how to make a script multi task based like this ? for($i=1;$i=100;$i++) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.facebook.com/ajax/reqs.php?__a=1' ); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERAGENT, Opera/9.80 (Windows NT 5.1; U; tr) Presto/2.6.22 Version/10.50); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_REFERER, http://www.facebook.com/reqs.php;); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_PROXY, 127.0.0.1:); curl_exec($ch); } ? lets say this takes 1000 seconds and it doesnt focus to another curl process before it finish the previous one is it possible to let the script focus another curl process without wait answer of the previous one i hope if u could understand me ^^
[PHP] a for loop and probability random all i need is make them to reverse
i want it returns *Raptor +1 (1 in 62,000) * but it returns me nearly everytime how can i make them reverse help me please index.php ? include( 'lib.probabilityRandom.php' ); $prExample = new probabilityRandom; function arasi($a,$b,$data) { $x = explode($a,$data); $z = explode($b,$x[1]); $oh = $z[0]; if($x $z) { return $oh; } else { return false; } } $x=Raptor +1 (1 in 62,000) Glave +1 (1 in 12,400) Chitin Armor Pauldron +1 (1 in 1,240) Full Plate Armor Pauldron +1 (1 in 310) Potion of Soul (1 in 83) Blade Axe +1 (1 in 62,000) Bone Cleaver +1 (1 in 12,400) Chitin Armor Pads +1 (1 in 1,240) Full Plate Armor Pads +1 (1 in 310) Potion of Wisdom (1 in 83) Graham +1 (1 in 62,000) Slayer +1 (1 in 12,400) Chitin Helmet +1 (1 in 1,240) Full Plate Armor Helmet +1 (1 in 310) Water of favors (1 in 83) Totemic Spear +1 (1 in 62,000) Harpoon +1 (1 in 12,400) Chitin Gauntlets +1 (1 in 1,240) Full Plate Armor Gauntlet +1 (1 in 310) Water of grace (1 in 83) Iron Bow +1 (1 in 62,000) Iron Crossbow +1 (1 in 12,400) Chitin Boots +1 (1 in 1,240) Full Plate Armor Boots +1 (1 in 310) Pink Rice Cake (small) (1 in 83) Elixir Staff +1 (1 in 62,000) Salamander Staff +1 (1 in 12,400) Rogue Chitin Armor Pauldron +1 (1 in 1,240) Rogue Full Plate Armor Pauldron +1 (1 in 310) Pink Rice Cake (middle) (1 in 83) Shard +1 (1 in 62,000) Mirage Dagger +1 (1 in 12,400) Rogue Chitin Armor Pads +1 (1 in 1,240) Rogue Full Plate Armor Pads +1 (1 in 310) Pink Rice Cake (large) (1 in 83) Priest Impact +1 (1 in 62,000) Priest Bone crasher +1 (1 in 12,400) Rogue Chitin Helmet +1 (1 in 1,240) Rogue Full Plate Armor Helmet +1 (1 in 310) Gold bar (1 in 620,000) Blessed Upgrade Scroll (1 in 12,400) Rogue Chitin Gauntlets +1 (1 in 1,240) Rogue Full Plate Armor Gauntlet +1 (1 in 310) Upgrade Scroll (1 in 83) Silver bar (1 in 62,000) Blessed Elemental Scroll (1 in 12,400) Rogue Chitin Boots +1 (1 in 1,240) Rogue Full Plate Armor Boots +1 (1 in 310) Crimson Robe +1 (1 in 1,240) Crystal Robe +1 (1 in 310) Green Rice Cake (small) (1 in 83) Crimson Pants +1 (1 in 1,240) Crystal Pants +1 (1 in 310) Green Rice Cake (middle) (1 in 83) Crimson Helmet +1 (1 in 1,240) Crystal Helmet +1 (1 in 310) Green Rice Cake (large) (1 in 83) Crimson Gloves +1 (1 in 1,240) Crystal Gloves +1 (1 in 310) Glutinous Rice Cake (1 in 83) Crimson Boots +1 (1 in 1,240) Crystal Boots +1 (1 in 310) Stone of life (1 in 83) Priest Chitin Armor Pauldron +1 (1 in 1,240) Priest Full Plate Armor Pauldron +1 (1 in 310) Bezoar (1 in 83) Priest Chitin Armor Pads +1 (1 in 1,240) Priest Full Plate Armor Pads +1 (1 in 310) Priest Chitin Helmet +1 (1 in 1,240) Priest Full Plate Armor Helmet +1 (1 in 310) Priest Chitin Gauntlets +1 (1 in 1,240) Priest Full Plate Armor Gauntlet +1 (1 in 310) Priest Chitin Boots +1 (1 in 1,240) Priest Full Plate Armor Boots +1 (1 in 310); $xx=explode( ,$x); $xcx=array(); foreach($xx as $c = $y) { $yy = arasi( in ,),$y); $yy = str_replace(,,,$yy); $xcx[]=$yy; #echo $yy.br; $itemisim = explode((,$y); $itemisim=$itemisim[0]; $xcx[isim][]=$itemisim; } for($i=0;$i=count($xcx)-1;$i++) { $prExample-add( $xcx[isim][$i], $xcx[$i] ); } print $prExample-get(); ? lib.probabilityRandom.php ?php /** - DEVELOPER --- Jonas Raoni Soares Silva Applications Developer [EMAIL PROTECTED] http://www.joninhas.ath.cx:666 - CLASS --- My user account at phpclasses.org http://www.phpclasses.org/browse.html/author/84147.html Get the latest version of this class at: http://www.phpclasses.org/browse.html/package/1940.html - VERSION HISTORY --- v1.0 2004-10-31 - Class creation - **/ class probabilityRandom { #private vars var $data = array(), $universe = 0; #add an item to the list and defines its probability of beeing chosen function add( $data, $probability ){ $this-data[ $x = sizeof( $this-data ) ] = new stdClass; $this-data[ $x ]-value = $data; $this-universe += $this-data[ $x ]-probability = abs( $probability ); } #remove an item from the list function remove( $index ){ if( $index -1 $index sizeof( $this-data ) ) { $item = array_splice( $this-data, $index, 1 ); $this-universe -= $item-probability; } } #clears the class function clear(){ $this-universe = sizeof( $this-data = array() ); } #return a randomized item from the list function get(){ if( !$this-universe ) return null; $x = round( mt_rand( 0, $this-universe ) ); $max = $i = 0; do $max += $this-data[ $i++ ]-probability; while( $x $max ); return $this-data[ $i-1 ]-value; } } ?
İlgi: [PHP] a for loop and probability random all i need is make them to reverse
sorry i think i did tell u wrong about it problem is not showing name of it as exaclty i just wanted give a point to it thats not real problem real problem is i want it be more unpossible when i give the class's add function's higher value 2008/11/22, Yeti [EMAIL PROTECTED]: That should output the full line now ? $prExample = new probabilityRandom; function arasi($a,$b,$data) { $x = explode($a,$data); $z = explode($b,$x[1]); $oh = $z[0]; if($x $z) { return $oh; } else { return false; } } $x=jZRBb9swDIXvA/YfdFyxHJK0GHadvc7tYUAQb+iZiWlHKGUFkpy1+/WTE7uzFcr1MSbz+NmPj1s4Om3E55X4tBKyFl/Wi+VyefPxQ0Zwwv/PV+vF3fl5epDO//5mlP/bBhoqjK4HfYv1Xdv2oyESGwKH0dbbVdu40U76p7oUuW6oK3299ZWEoPD/fkGGLtE1ipTQM5r3IQs7C3DYFsI9SVtoNcTLDBxAMWw5wesU1QOSQjeDKGy8MD35BtMilXDSxg6RfmmHSu5FfkTgPH0Ac9QjtwK0DJraEbo536vvjfJVBvY4xHts7U/0H4bsXEqNtnY3rId8idaz2IK+zkxZP4ut9EwpPHswq4DoZgh4T/JFGpE7KEvOWCBQUBd41fLGudVV4/XnZeTSPD8pAb+SRUE4eoH8AKZgyH9KAxWK71BV7Gay2FxqoshMdgJcAlONaTdGonXiUR1h7xjqrn7O+t6APbzPHstWhJtPWKapEDufoJ5n2V8dQmuxEL+Pfrf9bcr3RhNNAk0kKsIUyxU79OK6pPYMDokD4HtChbUDmoMcCVkEl41aaqSyfoO3eofXSql5tS3LuNp9e4NYT6e0F99AzXH26kE5Is+EqNeP7VI/ILI84YTrve8HZKRPOPEGYb0bQI13STd2OORaPOJir83alrs2av50kyyRSerMu9Z1zz5sCf7Vb7s7MY87SPFZzEUaqcbsjSnydo81J9Iek43FfSwccTMmyrj7Dw==; $x = gzinflate(base64_decode($x)); $xx=explode( ,$x); $xcx=array(); foreach($xx as $c = $y) { $yy = arasi( in ,),$y); $yy = str_replace(,,,$yy); $xcx[]=$yy; #echo $yy.br; $itemisim = explode((,$y); $itemisim=$itemisim[0]; $xcx[isim][]=$itemisim; } for($i=0;$i=count($xcx)-1;$i++) { $prExample-add( $xx[$i], $xcx[$i] ); // -- changed to $xx[i] } print $prExample-get(); class probabilityRandom { #private vars var $data = array(), $universe = 0; #add an item to the list and defines its probability of beeing chosen function add( $data, $probability ){ $this-data[ $x = sizeof( $this-data ) ] = new stdClass; $this-data[ $x ]-value = $data; $this-universe += $this-data[ $x ]-probability = abs( $probability ); } #remove an item from the list function remove( $index ){ if( $index -1 $index sizeof( $this-data ) ) { $item = array_splice( $this-data, $index, 1 ); $this-universe -= $item-probability; } } #clears the class function clear(){ $this-universe = sizeof( $this-data = array() ); } #return a randomized item from the list function get(){ if( !$this-universe ) return null; $x = round( mt_rand( 0, $this-universe ) ); $max = $i = 0; do $max += $this-data[ $i++ ]-probability; while( $x $max ); return $this-data[ $i-1 ]-value; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php