// ReSharper disable once UnusedMember.Global
第1行正在打印所有记录,但第2行只打印一条记录。为什么吗
答案 0 :(得分:0)
<?php
// if your products array is like this then it will result successfully
$array1 = Array
(
'0' => Array
(
'messageId' => 9,
'userId' => 47,
'petId' => 68,
'message' => 'how hello',
'senderId' => 48,
'senderPetId' => 66,
'messageCreateTime' => '2015-07-31 11:44:59'
),
'1' => Array
(
'messageId' => 8,
'userId' => 49,
'petId' => 69,
'message' => 'pppppppppp',
'senderId' => 48,
'senderPetId' => 67,
'messageCreateTime' => '2015-07-31 11:15:16'
),
'2' => Array
(
'messageId' => 6,
'userId' => 48,
'petId' => 67,
'message' => 'gggg',
'senderId' => 49,
'senderPetId' => 69,
'messageCreateTime' => '2015-07-31 11:13:42'
),
'3' => Array
(
'messageId' => 2,
'userId' => 48,
'petId' => 67,
'message' => 'aaaaaaaa',
'senderId' => 47,
'senderPetId' => 68,
'messageCreateTime' => '2015-07-31 11:15:33'
)
);
?>
<table border="1">
<?php foreach($array1 as $product){
?>
<tr>
<td align="center"><?php echo $product['messageId'] ?></td>
<td align="center"><?php echo $product['userId'] ?></td>
<td align="center"><?php echo $product['senderId'] ?></td>
<td align="center"><?php echo $product['messageCreateTime'] ?></td>
<td align="center">Edit / Delete</td>
</tr>
<?php } exit;?>
</table>
答案 1 :(得分:0)
其实朋友的问题在我的变量中。 <{1}}在我$product
时返回两个数组行和行,然后打印全部。
答案 2 :(得分:-2)
In [37]: s*= 1000
In [38]: timeit s[:2]+"."+s[2:]
1000000 loops, best of 3: 860 ns per loop
In [39]: timeit r.sub(r"\1.",s,1)
100000 loops, best of 3: 6.73 µs per loop