04. juli 2003 - 20:30
Der er
12 kommentarer og 1 løsning
Why Echoer den ikke den sidste bruger?
//Problem Why Echoer den ikke den sidste bruger? $words== Array ( [0] => :irc.funcom.com [1] => 353 [2] => doomtestbot [3] => = [4] => #AdrenalineRush [5] => :doomtestbot [6] => +[AO]DoomStone [7] => @DoomStone ) //Script $channel = $words[4]; $total_channels = count($words)-1; $i="5"; print_r($words); // Debug while($i<=$total_channels){ $words[$i]=str_replace(":", "", $words[$i]); $words[$i]=str_replace("@", "", $words[$i]); $words[$i]=str_replace("+", "", $words[$i]); Echo "'".$words[$i]."'==".$i." was put in to ".$channel."'s channel list\n"; $i++; } //Output 'doomtestbot'==5 was put in to #AdrenalineRush's channel list '[AO]DoomStone'==6 was put in to #AdrenalineRush's channel list '==7 was put in to #AdrenalineRush's channel list
Annonceindlæg tema
Cloud & AI
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
$channel = $words[4]; $total_channels = count($words); $i="5"; print_r($words); // Debug while($i<=$total_channels){ $words[$i]=str_replace(":", "", $words[$i]); $words[$i]=str_replace("@", "", $words[$i]); $words[$i]=str_replace("+", "", $words[$i]); Echo "'".$words[$i]."'==".$i." was put in to ".$channel."'s channel list\n"; $i++; }
Du havde en -> $total_channels = count($words)-1; Den minus en skal vel væk?
Nope den counter jo 1 formeget hvis jeg skal loope! den vil jo telle 0 som 1 og 1 som 2. da en array går 0 1 2 3 4. Men din version viker ikke :(
$channel = $words[4]; $total_channels = count($words); print_r($words); // Debug for ($i = 0; $i <= $total_channels; $i++){ $words[$i]=str_replace(":", "", $words[$i]); $words[$i]=str_replace("@", "", $words[$i]); $words[$i]=str_replace("+", "", $words[$i]); Echo "'".$words[$i]."'==".$i." was put in to ".$channel."'s channel list\n"; }
$channel = $words[4]; $total_channels = count($words); print_r($words); // Debug for ($i = 5; $i <= $total_channels; $i++){ $words[$i]=str_replace(":", "", $words[$i]); $words[$i]=str_replace("@", "", $words[$i]); $words[$i]=str_replace("+", "", $words[$i]); Echo "'".$words[$i]."'==".$i." was put in to ".$channel."'s channel list\n"; }
<?php $words[0] = ":irc.funcom.com"; $words[1] = "353"; $words[2] = "doomtestbot"; $words[3] = "="; $words[4] = "#AdrenalineRush"; $words[5] = ":doomtestbot"; $words[6] = "+[AO]DoomStone"; $words[7] = "@DoomStone"; $channel = $words[4]; $total_channels = count($words)-1; $i= 5; while ($i <= $total_channels { $words[$i]=str_replace(":", "", $words[$i]); $words[$i]=str_replace("@", "", $words[$i]); $words[$i]=str_replace("+", "", $words[$i]); echo "'".$words[$i]."'==".$i." was put in to ".$channel."'s channel list\n<br>"; $i++; } ?> Viser fint de tre sidste
men print_r($words) give [0] => :irc.funcom.com [1] => 353 [2] => doomtestbot [3] => = [4] => #AdrenalineRush [5] => :doomtestbot [0] => :irc.funcom.com [1] => 353 [2] => doomtestbot [3] => = [4] => #AdrenalineRush [5] => :doomtestbot [6] => +[AO]DoomStone [7] => @DoomStone Og den setter jo channel fint!
04. juli 2003 - 20:56
#10
[0] => :irc.funcom.com [1] => 353 [2] => doomtestbot [3] => = [4] => #AdrenalineRush [5] => :doomtestbot [6] => +[AO]DoomStone [7] => @DoomStone even :)
04. juli 2003 - 21:19
#11
Det er sten ikke? :( det virker som om at det sletter den sidste et eller andet sted men jeg kan ikke se noget sted den gør det!
04. juli 2003 - 23:27
#12
$words[$i]=str_replace(" ", "", $words[$i]); $words[$i]=str_replace("\n", "", $words[$i]); $words[$i]=str_replace("\r", "", $words[$i]); <-- Addet det og så virkrede det sq
04. juli 2003 - 23:27
#13
Svar
Vi tilbyder markedets bedste kurser inden for webudvikling