Jump to content

vivis933

Members
  • Content Count

    23
  • Joined

  • Last visited

Community Reputation

0 Neutral

About vivis933

  • Rank
    Member
  1. thank you i have tried with google api but it doesent get the correct location , sow the wiki is my last option. I changed the code a bit but i get error. can you suggest any wikitext parser. Or to save as array the text eg. the | to be the separator of arrays and the = to divide key and value with the explode function or something else $url1 = "https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Broadwood_Stadium&rvsection=0"; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_PROXYPORT, 3128); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); $response1 = curl_exec($ch1); curl_close($ch1); $response_a1 = json_decode($response1, true); $dist = $response_a1['query']['pages']; $dist2 = $response_a1['query']['pages'][$first_key]['revisions']; reset($dist); $first_key = key($dist); echo $first_key; print_r($dist2); $t = array_search("latd",$dist); echo $t; the echo of the firs key gives the correct number : 3750990.
  2. I need to extract data from this, i need latd , latm and lats. How to search the array and return the values ? result i need $latd = 55 $latm = 56 $lats = 41.19 $url1 = "https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Broadwood_Stadium&rvsection=0"; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_PROXYPORT, 3128); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); $response1 = curl_exec($ch1); curl_close($ch1); $response_a1 = json_decode($response1, true); $dist = $response_a1['query']['pages']; print_r($dist) ;
  3. This an example of what i need , basically the variable from first function to be included in the second function. <?php $number1 = 6 ; $number2 = 4 ; $number3 = 2 ; funct1($number1, $number2); funct2($variable1 , $number3); echo $variable2; function funct1($number1, $number2) { $variable1 = $number1 + $number2 ; } function funct2($variable1 , $number3) { $variable2 = $variable1 / $number3 ; } ?> ERROR
  4. It is possible to make it like the example below ? function funct1($number1, $number2) { $variable1 = $number1 + $number2 ; } function funct2($variable1 , $number3) { $variable2 = $variable1 / $number3 ; }
  5. First code <?php include("conf.php"); $fixtures_data = mysqli_query($conn,"SELECT Location,Date,HomeTeam,AwayTeam FROM datagmaes"); if ($fixtures_data->num_rows > 0) { // output data of each row while($row = $fixtures_data->fetch_assoc()) { $team1 = $row["HomeTeam"]; $team2 = $row["AwayTeam"]; } } else { echo "0 results"; } ?> Second code <?php include("conf.php"); include("poi.php"); $home = mysqli_query($conn,"SELECT Teamdata1 FROM gamesdata WHERE Team='$team1'"); $row1 = $home->fetch_assoc(); $hometeam = number_format($row1['Teamdata1'],2); $away = mysqli_query($conn,"SELECT Teamdata2 FROM gamesdata WHERE Team='$team2'"); $row2 = $away->fetch_assoc(); $awayteam = number_format($row2['Teamdata2'],2); $calAll = array(); /////All calculations for($goals = 0 ; $goals <= 9 ; $goals++) { array_push($calAll, (poi($goals,$hometeam) * poi(0,$awayteam))*100, (poi($goals,$hometeam) * poi(1,$awayteam))*100, (poi($goals,$hometeam) * poi(2,$awayteam))*100, (poi($goals,$hometeam) * poi(3,$awayteam))*100, (poi($goals,$hometeam) * poi(4,$awayteam))*100, (poi($goals,$hometeam) * poi(5,$awayteam))*100, (poi($goals,$hometeam) * poi(6,$awayteam))*100, (poi($goals,$hometeam) * poi(7,$awayteam))*100, (poi($goals,$hometeam) * poi(8,$awayteam))*100, (poi($goals,$hometeam) * poi(9,$awayteam))*100 ); } $result1 = number_format(array_sum($calAll),2); echo $result1 . "\n"; ?> The first code return multiple items i need to apply the second code to every item in first code and then to save $result1 in mysql table. First code results if echo $team1," vs ",$team2; scgohometeam1 vs csgoawayteam1 scgohometeam2 vs csgoawayteam2 scgohometeam3 vs csgoawayteam3 scgohometeam4 vs csgoawayteam4 scgohometeam5 vs csgoawayteam5 scgohometeam6 vs csgoawayteam6 ... etc. Thes desired final echo after combinin the two codes Final code results if echo $team1," vs ",$team2," = ", $result1 ; scgohometeam1 vs csgoawayteam1 = 25 scgohometeam2 vs csgoawayteam2 = 45 scgohometeam3 vs csgoawayteam3 = 40 scgohometeam4 vs csgoawayteam4 = 30 scgohometeam5 vs csgoawayteam5 = 15 scgohometeam6 vs csgoawayteam6 = 23 ... etc.
  6. <?php function factorial($number) { if ($number < 2) { return 1; } else { return ($number * factorial($number-1)); } } function poisson($occurrence,$chance) { $e = exp(1); $a = pow($e, (-1 * $chance)); $b = pow($chance,$occurrence); $c = factorial($occurrence); return $a * $b / $c; } $x = 2.5; $y = 1.5; $calAll = array(); for($z = 0 ; $z <= 9 ; $z++) { array_push($calAll, (poisson($z,$x) * poisson(0,$y))*100, (poisson($z,$x) * poisson(1,$y))*100, (poisson($z,$x) * poisson(2,$y))*100 ); } $value = max($calAll); $key = array_search($value, $calAll); print_r($calAll) . "\n"; echo "max =",$value , " key =",$key . "\n";; ?> it is possible to find $z and the number 0,1 or 2 from the max of the returned array ? I used excel to perform this action and i found that for max=8.5854557290941 the $z is 2 and number 1 how to achieve this in php ?
  7. I tryed with this but i get 8 values insteed 7 <?php $e = array(); for($x= 0 , $x1= 0; $x<= 3 || $x1<= 2; $x++ , $x1++ ) { array_push($e, (poisson($x,2.5) * poisson(0,3.5))*100, (poisson($x1,2.5) * poisson(1,3.5))*100///<--second variable ); } //echo array_sum($e) . "\n"; print_r($e) . "\n"; ?>
  8. It is possible in the second variable the loop for x to go til 9 not 10 starting from 0 not -1 $e = array(); for($x= 0 ; $x<= 10 ; $x++) { array_push($e, (poisson($x,2.5) * poisson(0,3.5))*100, (poisson($x,2.5) * poisson(1,3.5))*100)///<--second variable ); } echo array_sum($e) . "\n"; i add $x-1 $e = array(); for($x= 0 ; $x<= 10 ; $x++) { array_push($e, (poisson($x,2.5) * poisson(0,3.5))*100, (poisson($x-1,2.5) * poisson(1,3.5))*100)///<--second variable ); } echo array_sum($e) . "\n";
  9. Thank you i fixed it $e = array(); for($x= 0 ; $x<= 10 ; $x++) { array_push($e, (poisson($x+1,2.5) * poisson(0,3.5))*100); } echo array_sum($e) . "\n";
  10. for($x= 0 ; $x<= 10 ; $x++) { $e = (poisson($x+1,2.5) * poisson(0,3.5))*100; echo $e . "\n"; } I make this code from the poisson distribution and ercho return this How i can get the sum of all those numbers? I tryed to make the variable to array and to use sum_array bur it doesent give the correct resul for($x= 0 ; $x<= 10 ; $x++) { $e = array((poisson($x+1,2.5) * poisson(0,3.5))*100); } echo array_sum($e) . "\n"; echo return 0.00014805309341072
  11. @jacques1 thank you i was using excel for the possession distribution and the formula is this POISSON.DIST(x,mean,cumulative) X Required. The number of events. Mean Required. The expected numeric value. Cumulative Required. A logical value that determines the form of the probability distribution returned. If cumulative is TRUE, POISSON.DIST returns the cumulative Poisson probability that the number of random events occurring will be between zero and x inclusive; if FALSE, it returns the Poisson probability mass function that the number of events occurring will be exactly x. Sow in the example you prepossessed can you tell me which values present the x, mean and cumulative.
  12. Thank you for the reply , I need the to integrate the r code in php to make possession distribution for some data in database(mysql) sow i was searching for it and im not satisfied with the results , when i tried to install this library i got to much errors . If some one have a suggestion how to make a possession distribution in php with or without an external library please help me.
  13. Hi i need THIS package to install on windows using composer but im new here can some one help me.
  14. When i run the code without UNION and with one SELECT it works but when i try to run all together it wont insert data into table, or to try in different way without UNION, some help here. <?php include("conf.php"); $query = "INSERT INTO fund(Team, GamesPlayedHome, GoalsScorredHome, GoalsAcceptedHome, RedCardGotHome, AvarageGoalsScorredHome, AvarageGoalsAcceptedHome, GamesPlayedAway, GoalsScorredAway, GoalsAcceptedAway, RedCardGotAway, AvarageGoalsScorredAway, AvarageGoalsAcceptedAway) SELECT HomeTeam As Team, COUNT(HomeTeam) AS GamesPlayedHome, SUM(HomeGoals) AS GoalsScorredHome, SUM(AwayGoals) AS GoalsAcceptedHome, SUM(HomeRedCards) AS RedCardGotHome, SUM(HomeGoals) / COUNT(HomeTeam) AS AvarageGoalsScorredHome, SUM(AwayGoals) / COUNT(HomeTeam) AS AvarageGoalsAcceptedHome FROM GetHistoricMatchesByLeagueAndDateInterval GROUP BY HomeTeam ORDER BY HomeTeam ASC UNION ALL SELECT COUNT(AwayTeam) AS GamesPlayedAway, SUM(AwayGoals) AS GoalsScorredAway, SUM(HomeGoals) AS GoalsAcceptedAway, SUM(AwayRedCards) AS RedCardGotAway, SUM(HomeGoals) / COUNT(AwayTeam) AS AvarageGoalsScorredAway, SUM(AwayGoals) / COUNT(AwayTeam) AS AvarageGoalsAcceptedAway FROM GetHistoricMatchesByLeagueAndDateInterval GROUP BY AwayTeam ORDER BY AwayTeam ASC"; $data= mysqli_query($conn,$query) or die(mysqli_error()); while($row = mysqli_fetch_assoc($data)){ foreach($row as $cname => $cvalue){ print "$cname: $cvalue\t"; } print "\r\n"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.