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

Getting a value out of an array

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

Question by:hankknight
  • 3
LVL 27

Expert Comment

ID: 11779902
foreach ($results as $i)

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

Expert Comment

ID: 11779912
actually do it like this

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

Accepted Solution

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']);

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Query return divisible by 3 3 26
limit a company to search only coupons for that particular company 6 30
Moving from Mcrypt to OpenSSL 18 45
PHP Mail error 3 27
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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

837 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