Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
PHP array + function calling problem
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="GT9" data-source="post: 15230323" data-attributes="member: 478359"><p><span style="font-size: 12px"><span style="color: DarkRed">මචන්ලා මම php සම්බන්දව ගැටලුවක් තියෙනවා. <img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මෙන්න මේකයි ගැටලුව. <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මචන්ලා මම සරල php function එකක් ලිව්වා මේකෙන් වෙන්නේ function එක call කරන තැන්වලදි. එකක් මුල් අගයට එකතු වෙලා echo වෙන එක. <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /><img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මෙන්න මේකයි කෝඩ් එක.. </span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">[CODE]<?php</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">function nuAuInc()</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">{</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">static $x=0;</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">echo $x;</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">$x++;</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">}</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">nuAuInc();</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">nuAuInc();</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">nuAuInc();</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">?>[/CODE]</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">ඔය කෝඩ් එක run කරාම වෙන්නේ.. 012 echo වෙන එක.. ඉතින් එතන මට ගැටලුවක් නෑ...<img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /><img src="/styles/default/xenforo/smilies/default/cool.gif" class="smilie" loading="lazy" alt=":cool:" title="Cool :cool:" data-shortname=":cool:" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මට ගැටලුව එන්නේ මෙන්න මෙතෙන්දී...</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මේකයි මම පොඩි array එකක් හැදුවා.. මේතියෙන්නේ ඒක..<img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">[CODE]$names = array ("Sanka","Janith","Vidura","Roshen");</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">echo $names[3];[/CODE]</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මේ කෝඩ් එක රන් කරාම Roshen කියලා print වෙනවා.. එතනත් ගැටලුවක් නෑ..<img src="/styles/default/xenforo/smilies/default/baffled.gif" class="smilie" loading="lazy" alt=":baffled:" title="Baffled :baffled:" data-shortname=":baffled:" /><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">----------</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">ගැටලුව වෙන්නේ මෙන්න මේ දේ මම කරන්න ගියාම.. </span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">[CODE]<?php</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">$names = array ("Sanka","Janith","Vidura","Roshen");</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">echo $names[nuAuInc()];</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">?>[/CODE]</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මම දන්නෑ මචන් මේ දේ කරන්න පුලුවන්ද කියල..<img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/baffled.gif" class="smilie" loading="lazy" alt=":baffled:" title="Baffled :baffled:" data-shortname=":baffled:" /> මට කරගන්න ඕන මචන්..</span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">$names[3]; ඔන්න ඔය variable එකේ.. 3(array key index එක) වෙනුවට අර function එක (nuAuInc() එක) call කරන්න. මේදේ කරන්න පුලුවන්ද මචන්ලා? <img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">මම මෙහෙම කරාම.. Undefined index: කියල error එකක් එනව...<img src="/styles/default/xenforo/smilies/default/sorry.gif" class="smilie" loading="lazy" alt=":sorry:" title="Sorry :sorry:" data-shortname=":sorry:" /></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed"></span></span></p><p><span style="font-size: 12px"><span style="color: DarkRed">සරලවම මට දැනගන්න ඕන.. $names[3]; ඔන්න ඔය වගේ variable එකක array key index numbers වෙනුවට මගේ function එක call කරන්න..මම උත්සාහ කරා මේ විදියට.. $names[nuAuInc()]; ඒත් හරියන්නෑ.. error එකක් එනවනේ..<img src="/styles/default/xenforo/smilies/default/sorry.gif" class="smilie" loading="lazy" alt=":sorry:" title="Sorry :sorry:" data-shortname=":sorry:" /> මේ දේ කරන හැටි කියල දෙන්න ලොකු උදව්වක්.. <img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /><img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></span></span></p></blockquote><p></p>
[QUOTE="GT9, post: 15230323, member: 478359"] [SIZE="3"][COLOR="DarkRed"]මචන්ලා මම php සම්බන්දව ගැටලුවක් තියෙනවා. :yes: මෙන්න මේකයි ගැටලුව. :D මචන්ලා මම සරල php function එකක් ලිව්වා මේකෙන් වෙන්නේ function එක call කරන තැන්වලදි. එකක් මුල් අගයට එකතු වෙලා echo වෙන එක. :D:yes: මෙන්න මේකයි කෝඩ් එක.. [CODE]<?php function nuAuInc() { static $x=0; echo $x; $x++; } nuAuInc(); nuAuInc(); nuAuInc(); ?>[/CODE] ඔය කෝඩ් එක run කරාම වෙන්නේ.. 012 echo වෙන එක.. ඉතින් එතන මට ගැටලුවක් නෑ...:D:cool: මට ගැටලුව එන්නේ මෙන්න මෙතෙන්දී... මේකයි මම පොඩි array එකක් හැදුවා.. මේතියෙන්නේ ඒක..:yes: [CODE]$names = array ("Sanka","Janith","Vidura","Roshen"); echo $names[3];[/CODE] මේ කෝඩ් එක රන් කරාම Roshen කියලා print වෙනවා.. එතනත් ගැටලුවක් නෑ..:baffled::P:D ---------- ගැටලුව වෙන්නේ මෙන්න මේ දේ මම කරන්න ගියාම.. [CODE]<?php $names = array ("Sanka","Janith","Vidura","Roshen"); echo $names[nuAuInc()]; ?>[/CODE] මම දන්නෑ මචන් මේ දේ කරන්න පුලුවන්ද කියල..:rofl::baffled: මට කරගන්න ඕන මචන්.. $names[3]; ඔන්න ඔය variable එකේ.. 3(array key index එක) වෙනුවට අර function එක (nuAuInc() එක) call කරන්න. මේදේ කරන්න පුලුවන්ද මචන්ලා? :confused: මම මෙහෙම කරාම.. Undefined index: කියල error එකක් එනව...:sorry: සරලවම මට දැනගන්න ඕන.. $names[3]; ඔන්න ඔය වගේ variable එකක array key index numbers වෙනුවට මගේ function එක call කරන්න..මම උත්සාහ කරා මේ විදියට.. $names[nuAuInc()]; ඒත් හරියන්නෑ.. error එකක් එනවනේ..:sorry: මේ දේ කරන හැටි කියල දෙන්න ලොකු උදව්වක්.. :yes::D:yes:[/COLOR][/SIZE] [/QUOTE]
Insert quotes…
Verification
Winadiyakata thappara keeyak tibeda?
Post reply
Top
Bottom