1

I want to display array 1 by 1.. 1st array value display thnn 2nd array value

I want to display array data using loop and display data separatelylike 1st array data display then 2nd array data will display. and i want to display data only entrydate n description. with loop count

$svs= $user_posts->getvalue('service', $dsplylimit );

var_dump($svs);

My array is like this

array (size=2)
  0 => 
     array (size=46)
       0 => string '74' (length=2)
      'id' => string '74' (length=2)
       1 => string '0' (length=1)
      'author' => string '0' (length=1)
       2 => string '2016-02-08 07:32:08' (length=19)
      'entrydate' => string '2016-02-08 07:32:08' (length=19)
       3 => string '2016-02-08 01:32:08' (length=19)
      'date_gmt' => string '2016-02-08 01:32:08' (length=19)
       4 => string 'nice email' (length=10)
      'description' => string 'nice email' (length=10)
  1 => 
     array (size=46)
       0 => string '75' (length=2)
       'id' => string '75' (length=2)
       1 => string '0' (length=1)
       'author' => string '0' (length=1)
       2 => string '2016-02-08 11:15:40' (length=19)
       'entrydate' => string '2016-02-08 11:15:40' (length=19)
       3 => string '2016-02-08 05:15:40' (length=19)
       'date_gmt' => string '2016-02-08 05:15:40' (length=19)
       4 => string 'hiiiiiii' (length=8)
       'description' => string 'hiiiiiii' (length=8)

1 Answer 1

1

It isn't very clear what you want to do, but you can probably display the data with a foreach loop. Just loop through each array, and then print out the values from each iteration that you want.

For example for the following array

$data = [
    ['entrydate' => '2016-01-01', 'description' => 'Some description here'],
    ['entrydate' => '2016-01-02', 'description' => 'Another description here']
];

You could print out the data like so:

$html = '';

foreach ($data as $array) {
    $html .= '<h1>' . htmlspecialchars($array['entrydate']) . '</h1>';
    $html .= '<p>' . htmlspecialchars($array['description']) . '</p>';
}

echo $html;

For the following output:

2016-01-01

Some description here

2016-01-02

Another description here

There's a chance I'm not understanding your requirements, if so just let me know, but I'm not 100% sure what it is you're after.

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

2 Comments

i wnt to display entrydate in <h1> tag ex.. <h1>entrydate</h1> already i give u my array data how to display entrydate in <h1> tag?? @Virtual Pigeon
@KevinPPatel Updated my answer, feel free to see if that is what you need.

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.