Solved

Getting a value out of an array

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 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