didy Posted March 10, 2009 Report Share Posted March 10, 2009 (edited) Velos izveidot funkciju kura ietilpst vairaki defineti masiivi. Pie funkcijas izvades noradot vienu no masiviem un redzet izdrukatu masiivu rezultatu. <?php function auglis($auglis){ $apple = array('apals', 'sarkans', 'koka'); $kartupelis = array('ovals', 'bruns', 'zemee'); echo "$auglis[0], $auglis[1], $auglis[2]"; } auglis($auglis = $apple); ?> Izlabojiet, ko daru nepareizi. Edited March 10, 2009 by didy Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted March 10, 2009 Report Share Posted March 10, 2009 http://www.catb.org/~esr/faqs/smart-questions.html Quote Link to comment Share on other sites More sharing options...
didy Posted March 10, 2009 Author Report Share Posted March 10, 2009 Prieks, kad esi izlasijis. Quote Link to comment Share on other sites More sharing options...
Kaklz Posted March 10, 2009 Report Share Posted March 10, 2009 Ja pareizi sapratu, tad palasi par Variable Variables (http://lv.php.net/language.variables.variable) un reku vajadzētu būt tam, ko tu tur mēģini izzīlēt: <?php function auglis($auglis){ $apple = array('apals', 'sarkans', 'koka'); $kartupelis = array('ovals', 'bruns', 'zemee'); $auglis = $$auglis; echo "$auglis[0], $auglis[1], $auglis[2]"; } auglis('apple'); ?> un starp citu kartupelis ir dārzenis, nevis auglis :) Quote Link to comment Share on other sites More sharing options...
didy Posted March 11, 2009 Author Report Share Posted March 11, 2009 Loti patikami, paldies! augli/darzeni - Tas jau tikai piemeers :) 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.