Sephy Posted April 21, 2008 Report Share Posted April 21, 2008 vai ir iepejams izveidot piemeram no skaitla $skaitlis="1337"; masivu piemeram: $cipars[0] = 1; $cipars[1] = 3; $cipars[2] = 3; $cipars[3] = 7; Link to comment Share on other sites More sharing options...
bubu Posted April 21, 2008 Report Share Posted April 21, 2008 $cipars = array_map(intval, explode("", $skaitlis)); Link to comment Share on other sites More sharing options...
Aleksejs Posted April 21, 2008 Report Share Posted April 21, 2008 jā! String jau automātiski ir masīvs - tobiš ja tev ir: $skaitlis="1337"; tad jau bez nekādām citām manipulācijām vari katru atsevišķo simbolu dabūt kā: $skaitlis[0], $skaitlis[1] utt Link to comment Share on other sites More sharing options...
Sephy Posted April 21, 2008 Author Report Share Posted April 21, 2008 hmm paldies izklausas labi Link to comment Share on other sites More sharing options...
andrisp Posted April 21, 2008 Report Share Posted April 21, 2008 (edited) Aleksej, tā gluži nav, man liekas, ka string ir masīvs. Piemēram, foreach nestrādās. Edited April 21, 2008 by andrisp Link to comment Share on other sites More sharing options...
Aleksejs Posted April 21, 2008 Report Share Posted April 21, 2008 Nu, jā, visas masīva īpašības nav, tomēr atsevišķus simbolus gan tā var dabūt ārā: String access and modification by character Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. Think of a string as an array of characters for this purpose. Link to comment Share on other sites More sharing options...
Sephy Posted April 21, 2008 Author Report Share Posted April 21, 2008 kapeec mans cikls netradaaa!? <?php for($n=0,n$=31,n++){ if $binarais[n]=1 echo "<br> binarais $n ir vienads ar viens!!"; } ?> Link to comment Share on other sites More sharing options...
andrisp Posted April 21, 2008 Report Share Posted April 21, 2008 (edited) ai labāk neizteikšos :> Edited April 21, 2008 by andrisp Link to comment Share on other sites More sharing options...
Aleksejs Posted April 21, 2008 Report Share Posted April 21, 2008 (edited) Tāpēc, ka esi ātrumā uzrakstījis = bet vajadzēja == P.S. ā, jā! :D un arī viss tas, ko Andris pierakstīja! P.P.S. Un cik ātri pierakstīja, tik ātri arī izdzēsa ;) Edited April 21, 2008 by Aleksejs Link to comment Share on other sites More sharing options...
Sephy Posted April 21, 2008 Author Report Share Posted April 21, 2008 (edited) for ($i = 0; $i <= 31; $i++) { if ($binarais[$i]==1) echo "<br> binarais nummur $i ir vienads ar viens!!"; } viss stradaa nwm xD. kluda laikam bij tur ka nesaliku atstarpes oO Edited April 21, 2008 by Sephy Link to comment Share on other sites More sharing options...
Aleksejs Posted April 21, 2008 Report Share Posted April 21, 2008 Nu, nezinu... piemēram no šī koda gabala vispār nav skaidrs vai tas $binarais ir nodefinēts. Link to comment Share on other sites More sharing options...
andrisp Posted April 21, 2008 Report Share Posted April 21, 2008 $n=31 -> $n == 31 Link to comment Share on other sites More sharing options...
Sephy Posted April 21, 2008 Author Report Share Posted April 21, 2008 nakamais jautajums: kaa lai uztaisa lai izlaizh dazhu vertibu parbaudi. pashlaik ir: if ($i==0 or $i==1 or $i==3 or $i==7 or $i==15 or $i=31){break;} bet sitais laikam vispaar partrauc cikla izpildi Link to comment Share on other sites More sharing options...
andrisp Posted April 21, 2008 Report Share Posted April 21, 2008 php.net/continue Link to comment Share on other sites More sharing options...
Sephy Posted April 21, 2008 Author Report Share Posted April 21, 2008 paldies ;] viss stradaa Link to comment Share on other sites More sharing options...
Recommended Posts