Jump to content

Values in array


kiggs1881

Recommended Posts

I have values in an array "details". I am using a foreach loop to display the information, but <?php echo $row['details']; ?> pulls out all the values in the array. How to I only pull out one value, for example the second value, in the array rather than all of them? More specifically, I would like to put each value from that array into a separate cell in a table.

 

Any help from you all would be sooo great. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/205296-values-in-array/
Share on other sites

Here you go: this is the foreach loop, let me know if you need something else:

 

 <?php foreach ($rows as $count => $row): ?>
      <tr>
        <?php foreach ($row as $field => $content): ?>
          <td>
            <?php echo $row['details']; ?>
          </td>        <?php endforeach; ?>

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/205296-values-in-array/#findComment-1074523
Share on other sites

I can tell there's a problem here. You say that $row is an array so you probably want to echo $content instead?

 

Here you go: this is the foreach loop, let me know if you need something else:

 

 <?php foreach ($rows as $count => $row): ?>
      <tr>
        <?php foreach ($row as $field => $content): ?>
          <td>
            <?php echo $row['details']; ?>
          </td>        <?php endforeach; ?>

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/205296-values-in-array/#findComment-1074530
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.