0
array(10) {
   "name" => "samn" (10)
   "email" => "[email protected]" (20)
   "title" => "hello world" (8)
   "postcode" => "55555" (5)
   "telephone" => "123123123" (9)
   "category_id" => FALSE
}

how to foreach selected data? i mean something like this

foreach($data as $row)
{
   echo $row->email;
   echo $row->title;
}

2 Answers 2

4
foreach($data as $row)
{
   echo $row['email'];
   echo $row['title'];
}

You should go through an intro tutorial to PHP or something.

Sign up to request clarification or add additional context in comments.

2 Comments

i'm getting the error Arrayssa A PHP Error was encountered Severity: Notice Message: Uninitialized string offset: 0 Filename: ai/ai.php Line Number: 84 A PHP Error was encountered Severity: Notice Message: Uninitialized string offset: 0 Filename: form.php Line Number: 84 1p
are you sure you're initializing $data properly?
2

Reference associative array elements using array notation. Like this:

foreach($data as $row)
{
   echo $row["email"];
   echo $row["title"];
}

The -> operator is object notation and not applicable in your example.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.