PHP Array Function Questions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gongzhen
Forum Newbie
Posts: 2
Joined: Fri Nov 12, 2010 2:40 am

PHP Array Function Questions

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP Array Function Questions

Post 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/
There are 10 types of people in this world, those who understand binary and those who don't
gongzhen
Forum Newbie
Posts: 2
Joined: Fri Nov 12, 2010 2:40 am

Re: PHP Array Function Questions

Post by gongzhen »

Hi..thanks guys.. But my instructors required use two arrays and link them with PHP functions.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP Array Function Questions

Post by VladSun »

So, do your homework first:
http://php.net/manual/en/ref.array.php
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply