Paul Paul - 13 days ago 7
CSS Question

Wrapping each individual array data piece in its own div

I am running into a problem with an imploding list. The data is correct, but I cannot figure out how to put it into a format to where each result (piece of data) is wrapped into the div I am attempting to surround it with:

$pending_friend_list = '<div class="pending-friend-list-row">'. implode($friends_pending_arr) . '</div>';

I am wanting it to appear like this:

<div class="pending-friend-list-row">1</div>

<div class="pending-friend-list-row">2</div>

<div class="pending-friend-list-row">3</div>

All this is doing now is putting all of the imploded data into one div like,
<div class="pending-friend-list-row">123</div>

Any ideas?

Full code:

$friends_pending_arr = array();
$friends_pending_sql = "
FROM friends
WHERE friend_two = ?
AND status = ?
$pending_friend_count_stmt = $con->prepare($friends_pending_sql);
$pending_friend_count_stmt->execute(array($user_id, $status_one));
$pending_friend_rows = $pending_friend_count_stmt->fetchAll(PDO::FETCH_ASSOC);
echo '<div id="pending-request_count">Total Pending Friends -' . $total_pending_count . '</div>';
foreach ($pending_friend_rows as $pending_friend_row) {
$pending_friend_1 = $pending_friend_row['friend_one'];
$pending_friend_2 = $pending_friend_row['friend_two'];
$pending_friend_status = $pending_friend_row['status'];
$pending_friend_status_date = $pending_friend_row['date'];
$total_pending_friends = $pending_friend_1 . "<br>" . $pending_friend_2;

if ($pending_friend_2 == $user_id) {
$friends_pending_arr[] = $pending_friend_1;
//echo implode("<br>",$friends_pending_arr);
//$pending_friend_list = implode("<br>",$friends_pending_arr);
$pending_friend_list = '<div class="pending-friend-list-row">'. implode($friends_pending_arr) . '</div>';
echo $friend_status_button . "<br>";
echo $profile_viewer_message;
<div id="main">
<div id="pending-friend-list-container">
<div id="pending-friend-list-summary">
<?php //echo '<div class="pending-friend-list-row">'. $pending_friend_list . '</div>';
echo $pending_friend_list;


.pending-friend-list-row {
height: 50px;
width: 100%;
border: 1px solid green;
background: gray;

ccs ccs

You want your glue to end one div and start the next like this:

$pending_friend_list = '<div class="pending-friend-list-row">'. implode('</div><div class="pending-friend-list-row">', $friends_pending_arr) . '</div>';

More on how to use glue with implode