euphoric Posted February 21, 2010 Report Share Posted February 21, 2010 Pārstrādājies laikam esmu... Nesaprotu kur kļūda, palīdziet lūdzu. function check_captcha($input) { $i = -1; do { $i++; $a."_".$i = substr($input,$i,1); }while($i <= 4); } check_captcha('1234'); kpc nav mainīgo $a_0;$a_1;$a_2;$a_3; ? Quote Link to comment Share on other sites More sharing options...
InTrance Posted February 21, 2010 Report Share Posted February 21, 2010 vai tad netrūkst kaut kas? function check_captcha($input) function check_captcha($input); šādi? Quote Link to comment Share on other sites More sharing options...
Kemito Posted February 22, 2010 Report Share Posted February 22, 2010 InTrance - Viņš veido funkciju nevis to izsauc! Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted February 22, 2010 Report Share Posted February 22, 2010 $tmp=$a."_".$i; $$tmp = substr($input,$i,1); Quote Link to comment Share on other sites More sharing options...
marcis Posted February 22, 2010 Report Share Posted February 22, 2010 (edited) Eksistē arī vēl eval() variants un vēl daži interesantāki ${$a."_".$i} = substr($input,$i,1); $myarray = array(); // php semikols aizmirsās :) do{ $i++; $myarray[$a."_".$i] = substr($input,$i,1); }while($i <= 4); extract($myarray); Edited February 22, 2010 by marcis Quote Link to comment Share on other sites More sharing options...
briedis Posted February 22, 2010 Report Share Posted February 22, 2010 (edited) +1 par extract metodi :) vieglāk debugot (print_r($myarray))... Bet ja godīgi, vai tiešām tev vajag definēt mainīgos tā?? Edited February 22, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
bubu Posted February 22, 2010 Report Share Posted February 22, 2010 Ir taču tāda lieta kā masīvi: function check_captcha($input) { $i = -1; $a = array(); do { $i++; $a[$i] = $input[$i]; } while($i <= 4); } check_captcha('1234'); Un kamdēļ no stringa jāvelk atsevišķi čari ārā atsevišķos mainīgos? Lieto $input[4] sintaksi, kur 4 ir indekss stringā. Quote Link to comment Share on other sites More sharing options...
waplet Posted February 22, 2010 Report Share Posted February 22, 2010 tas jau būš 5 letteru vārdam. Quote Link to comment Share on other sites More sharing options...
euphoric Posted February 23, 2010 Author Report Share Posted February 23, 2010 ah, paldies visiem, noderēs... No rīta pamodos un sapratu, ka kartējo reizi visu sarežģīju, iztiku vispar bez tā visa.. :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.