Page 1 of 1

PHP Array Function Questions

Posted: Fri Nov 12, 2010 2:53 am
by gongzhen
Hi, I am new in PHP and I wanna finish a small assignment. it sounds easy but hard for me. I wish somebody can help me and give me support. I will appreciate it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 an array with a list of URLs (minimum 3)
2 an array with a list of website names (minimum 3)
3 PHP code to create an unordered list of links using the two arrays you created above
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My code looks like that:
<div>
<?php

$info1 = array1{ 'http://www.yahoo.com','http://www.google.com' };
$info2= array2{ 'Yahoo','Google' };
<ul>
<li></li>
<li></li>

</ul>
?>
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have no idea how to connect the two arrays together with php function.
please give me some ideas.

thanks :D :D :D :D

Re: PHP Array Function Questions

Posted: Fri Nov 12, 2010 3:01 am
by VladSun
1. Wrong syntax. Should be

Code: Select all

$info1 = array( 'http://www.yahoo.com','http://www.google.com' );
2. You may use so called hashes instead of plain arrays:

Code: Select all

$info1 = array('Yahoo' => 'http://www.yahoo.com', 'Google' => 'http://www.google.com' );
3. Start reading the manual ;) http://www.php.net/manual/en/

Re: PHP Array Function Questions

Posted: Fri Nov 12, 2010 3:13 am
by gongzhen
Hi..thanks guys.. But my instructors required use two arrays and link them with PHP functions.

Re: PHP Array Function Questions

Posted: Fri Nov 12, 2010 3:19 am
by VladSun
So, do your homework first:
http://php.net/manual/en/ref.array.php