Solved

Getting a value out of an array

Posted on 2004-08-11
3
217 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
  • 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 375 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is this error or Notice in php error log? 6 32
WordPress Themes 10 34
WordPress website error - Unable to access website. 5 28
is this a cms? 8 33
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

929 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now