I have:
email (ex: xxx@domain.com ), password and domain (ex: 'domain.com')
I want to modify this array to get:
a = [1,2,4,5]
This can be done with an a #=> [1,0,0,0]
loop, but I'm trying not to use a loop here. Here's my code:
each
答案 0 :(得分:7)
You can use fill
:
echo "<table id='table'>";
while($row=pg_fetch_assoc($result)){echo "<tr>";
echo "<td align='left' width='200'>" . $row['message_by'] . "</td>";
echo "<td align='left' width='200'>" . $row['message_date'] . "</td>";
echo "<td align='left' width='200'>" . $row['message_text'] . "</td>";
echo "<td align='left' width='200'>" . $row['phone_number'] . "</td>";
echo "<td align='left' width='200'>" . $row['recipient_name'] . "</td>";
echo "</tr>";}
echo "</table>";
The above code sets the elements in a = [1, 2, 4, 5]
#=> [1, 2, 4, 5]
a.fill(0, 1)
#=> [1, 0, 0, 0]
a
#=> [1, 0, 0, 0]
to a
, starting at index 0
.