Solved

Getting a value out of an array

Posted on 2004-08-11
3
216 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
Comment Utility
foreach ($results as $i)

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

Expert Comment

by:Diablo84
Comment Utility
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
Comment Utility
you could do it using foreach, in which case it would have to be

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

771 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

10 Experts available now in Live!

Get 1:1 Help Now