?
Solved

Getting a value out of an array

Posted on 2004-08-11
3
Medium Priority
?
228 Views
Last Modified: 2006-11-17
I create and fill an array like this:

$results[] = array("url" => $row1->URL, "title" => $row1->Title);


I tried to get the "Title" out of it like this:

foreach ($results as $i)

{
print ($results[$i]->title);
}


but it doesn't work . . .

Thanks!
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 27

Expert Comment

by:Diablo84
ID: 11779902
foreach ($results as $i)

{
print ($results[$i]['title']);
}
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11779912
actually do it like this

for($i=0;$i<count($results);$i++) {
 print ($results[$i]['title']);
}
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 1500 total points
ID: 11779919
you could do it using foreach, in which case it would have to be

foreach ($results as $i) {
print ($i['title']);
}
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question