Solved

Getting a value out of an array

Posted on 2004-08-11
3
221 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 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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 …
This article discusses four methods for overlaying images in a container on a web page
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 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