Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,908 members, 7,814,069 topics. Date: Wednesday, 01 May 2024 at 05:25 AM

Try This Simple Quiz. ** Solved ** ** Prize Awarded ** - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Try This Simple Quiz. ** Solved ** ** Prize Awarded ** (1062 Views)

Are You Making Enough Money From Adsense? Try This Instead. / Enter For All Wapka Codes/get Your Wapka Site's Problems Solved / Most Confusing And Simple Maths Quiz (2) (3) (4)

(1) (Reply) (Go Down)

Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 4:54pm On May 30, 2011
Difficulty level: I think its okay to say beginnerĀ  grin

Here's the quiz


<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

$no_of_babes = count($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i++){
?>
<a href="#"><?php echo $babes[$i] ?></a>,
<?php
}
?>
</p>

The output of the above code gives me something like. . .
angela, patricia, ella, afrobaby, yawa,

Modify the for() loop to give me this
angela, patricia, ella, afrobaby, yawa.


In other words, the comma after "yawa" should be replaced with full stop cuz its the end of the list.

I don't think there's only one way of doing this so any way you think you can do this, do am.

Prize: First correct answer from a beginner wins the person a free hosting account and domain on the TruDigits Starter Plan, for one year. Terms, conditions and acceptable usage policies apply strictly.

P.S: sorry if you don't like the way i escape into html from php. I'm used to writing that way.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by ogzille(m): 8:18pm On May 30, 2011
am i entitled to the prize? the hosting na?
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 8:38pm On May 30, 2011
lol, after 24 hours if no beginner or intermediate gets it then you can post yours.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by WeMaStEr(m): 8:58pm On May 30, 2011
scared of bot grin grin grin grin grin
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 9:10pm On May 30, 2011
I dont think the bots will worry since all thats to be done is a modification to the code I have already posted. The bots didnt touch me when I posted it. You can however put your codes in pastebin.com and post the link here.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 9:49pm On May 30, 2011
Why are you using the name of all my GFs?
Dual Core:

I dont think the bots will worry since all thats to be done is a modification to the code I have already posted. The bots didnt touch me when I posted it. You can however put your codes in pastebin.com and post the link here.
or they canĀ  post their reply with the nairaland-spambot-killer! ()
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 9:50pm On May 30, 2011
abi o.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by yawatide(f): 11:40pm On May 30, 2011
kai, na wa o! Dual, how did u become a coder? y rnt u a porn star? tongue
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by sisqology(m): 2:52am On May 31, 2011
<?php
$babes = array("angela",
"patricia", "ella", "afrobaby",
"yawa"wink;
$no_of_babes = count
($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i+
+){
?>
<a href="#"><?php echo
$babes[$i] ?></a>.
<?php
}
?>
</p>
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 7:23am On May 31, 2011
yawa-ti-de:

kai, na wa o! Dual, how did u become a coder? y rnt u a indecency star? tongue
LoL yawa, na tony spoil me grin


sisqology:

<?php
$babes = array("angela",
"patricia", "ella", "afrobaby",
"yawa"wink;
$no_of_babes = count
($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i+
+){
?>
<a href="#"><?php echo
$babes[$i] ?></a>.
<?php
}
?>
</p>


The output I am getting from your code is
angela. patricia. ella. afrobaby. yawa.

The correct output should be
angela, patricia, ella, afrobaby, yawa.


Modify your for() loop again bro and retry.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by sisqology(m): 9:53am On May 31, 2011
<?php
$babes = array("angela",
"patricia", "ella", "afrobaby",
"yawa"wink;
$no_of_babes = count
($babes);
?>
<p>
<?php
for($i=0;$i<=$no_of_babes;$i+
+){
?>
<a href="#"><?php echo
$babes[$i] ?></a>,
<?php
}
?>
</p>
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Otuabaroku: 9:55am On May 31, 2011
And the solution is:
<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

$no_of_babes = count($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i++){
if($i==$no_of_babes-1)
{
?>
<a href="#"><?php echo $babes[$i] ?></a>.
<?php
}
else
{
?>
<a href="#"><?php echo $babes[$i] ?></a>,
<?php
}
}
?>
</p>
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 11:06am On May 31, 2011
sisqology:

<?php
$babes = array("angela",
"patricia", "ella", "afrobaby",
"yawa"wink;
$no_of_babes = count
($babes);
?>
<p>
<?php
for($i=0;$i<=$no_of_babes;$i+
+){
?>
<a href="#"><?php echo
$babes[$i] ?></a>,
<?php
}
?>
</p>



I ran this and this is what I am getting
angela, patricia, ella, afrobaby, yawa, ,


still not correct.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 11:10am On May 31, 2011
Otuabaroku:

And the solution is:
<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

$no_of_babes = count($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i++){
if($i==$no_of_babes-1)
{
?>
<a href="#"><?php echo $babes[$i] ?></a>.
<?php
}
else
{
?>
<a href="#"><?php echo $babes[$i] ?></a>,
<?php
}
}
?>
</p>



Correct smiley

Place an order with the link below and update this thread with your invoice number. Also update this thread with an explanation of the concept in your solution for the benefit of everyone.

https://www.trudigits.com/cart.php?a=add&pid=14


Quiz Solved


Others who have other ways of getting this solved do well to post.

My own solution is similar to the winner's, so his explanation should cover mine.


<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

$no_of_babes = count($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i++){
?>
<a href="#"><?php echo $babes[$i] ?></a><span <?php if($i == $no_of_babes - 1){ ?>style="display:none"<?php } ?>>, </span><?php if($i == $no_of_babes - 1){ ?>.<?php } ?>
<?php

}

?>
</p>
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Otuabaroku: 11:39am On May 31, 2011
<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

$no_of_babes = count($babes);
?>
<p>
<?php
for($i=0;$i<$no_of_babes;$i++) // The for loop is meant to loop through the array(babes grin) and print them
{
if($i==$no_of_babes-1) /*Check if the loop has reached the end of the array; the end is when the iterator($i) is equal to the length of the array($no_of_babes) less by one because array index starts by 0 */
{
// if it has reached the end the array, print the last element with fullstop.
?>
<a href="#"><?php echo $babes[$i] ?></a>.
<?php
}
else
{
// if it has not reached the end of the loop, the print the element of array with comma,

?>
<a href="#"><?php echo $babes[$i] ?></a>,
<?php
}
}
?>
</p>

Hope the comment to my code now is explanatory enough. My oga Dual core, thank you so much for the prize, I feel happy and I am dedicating it to sisqology for his effort so far. in order words I want him to take my prize. My oga, once again, thank you.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 11:45am On May 31, 2011
Thank you very much for your generosity. It is impressive.

Sisqology, please follow that link above and place the order. Update this thread with just the invoice number.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 12:21pm On May 31, 2011
All your solutions are not clean oop - they are almost as terrible as using <?php babes_dump($dual_babes);?>
babes_dump is an oop version of var_dump. Another similar code is bang_dump which has similar usages.

I will actually post the codes soon enough. . . .
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 12:31pm On May 31, 2011
<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

function show_babes($babes) {
$out="<p>";$arr=Array();
foreach($babes as $babe) {
$arr[]="<a href='javascript:alert('$babe');'>$babe</a>";
}
$out='<p>'.implode(", ",$arr).'.</p>';
echo $out;
}

show_babes($babes);
?>
This is correct - i know, thank you. It is an oop version of the code posted above
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 12:33pm On May 31, 2011
<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;

function bang_babes($babes) {
$out="<p>";$arr=Array();
foreach($babes as $babe) {
$arr[]="<a href='javascript:alert('$babe');'>Dont bang $babe</a>";
}
$out='<p>'.implode(", ",$arr).'.</p>';
echo $out;
}

bang_babes($babes);
?>

You can figure out the third oop code yourself. . .
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 12:41pm On May 31, 2011
*dhtml:

<?php babes_dump($dual_babes);?>

God forbid.

Thanks for your contributions tho.

More solutions welcome. It don't have to be clean OOP. It has to be something tht works . . . OOP or PDP
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 1:03pm On May 31, 2011
PDP as in People Destroying People?
wait up, my first code works and does similar work as yours. . .

And now, i will come up with another shorter version of the solution again
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 1:09pm On May 31, 2011
This is the PDP / The Ogbonge Version / No-Arrays Version:


<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;
$bang=implode(",",$babes);
$dump="<a href='#'>".str_replace(",","</a>, <a href='#'>",$bang) . "</a>.";
echo $dump;
?>
. . . .corecta o no corecta?
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 3:23pm On May 31, 2011
si, corecta.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 7:31pm On May 31, 2011
And now, the same thing again - in a funkified manner


<?php
$babes = array("angela", "patricia", "ella", "afrobaby", "yawa"wink;
foreach($babes as $bang=>$dump) {
$babes[$bang]="<a href='#'>" . $dump ."</a>";
}
$leave=implode(", ",$babes);
echo $leave . '.';
?>

Since the correct order is: bang then leave / dump (semantics)

Yo, all these codes i am writing are for the benefits of newbies to learn
that there are many ways to solve problems.
In some instances, you get to continue a work that someone has been
doing before, so you must understand that there are many ways of achieving
the same results - though by default, we all have our methods.

Disclaimer: None of these babes (dunno of other babes sha) aforementioned were harmed by us in any way in the making of this thread or these codes.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by yawatide(f): 8:26pm On May 31, 2011
Disclaimer: None of these babes (dunno of other babes sha) aforementioned were harmed by us in any way in the making of this thread or these codes.

There are many ways to harm, so which is it? Mentally, psychologically or physically? tongue
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 9:22pm On May 31, 2011
yawa-ti-de:

There are many ways to harm, so which is it? Mentally, psychologically or physically? tongue
Well, i knew someone will say this: pero they were not harmed as far as i was concerned. . .they are all my amigas anyway
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 10:49pm On May 31, 2011
Before *dhtml came into this thread end($babes) was cat walking perfectly well, now she is limping.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 7:03am On Jun 01, 2011
Cat-walking keh? that is because they were not properly handled. . .
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by sisqology(m): 1:16am On Jun 02, 2011
Dual Core:

Thank you very much for your generosity. It is impressive.

Sisqology, please follow that link above and place the order. Update this thread with just the invoice number.



Invoice #1640
Invoice Date: 02/06/2011
Due Date: 04/06/2011

Thanks bro,


Otuabaroku:



Hope the comment to my code now is explanatory enough. My oga Dual core, thank you so much for the prize, I feel happy and I am dedicating it to sisqology for his effort so far. in order words I want him to take my prize. My oga, once again, thank you.


Nice one there, thanks for being generous,



back to refresh mode grin grin grin grin grin grin grin grin grin
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Nobody: 6:14am On Jun 02, 2011
lol
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by DualCore1: 8:21am On Jun 02, 2011
sisqology:


Invoice #1640
Invoice Date: 02/06/2011
Due Date: 04/06/2011

Thanks bro,



Nice one there, thanks for being generous,



back to refresh mode grin grin grin grin grin grin grin grin grin

Your domain http://temitopsy.com/ and its hosting are ready for use. Please check your mail for your account details.
Re: Try This Simple Quiz. ** Solved ** ** Prize Awarded ** by Otuabaroku: 2:27pm On Jun 02, 2011
sisqology:


Invoice #1640
Invoice Date: 02/06/2011
Due Date: 04/06/2011

Thanks bro,



Nice one there, thanks for being generous,



back to refresh mode grin grin grin grin grin grin grin grin grin

You are welcome, enjoy!!

(1) (Reply)

Interesting Timeline: The Evolution Of Advertising Infographic / Truth About Unlimited Webhosting Plans / How To Make Money Online By Selling Information Products In Nigeria

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 48
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.