这是我的代码
<?php
$something = array();
while ($row = mysql_fetch_assoc($result)) {
$something[] = $row;
}
mysql_close($con);
?>
<script type="text/javascript">
some= <?php echo json_encode($something); ?>;
</script>
上面的代码会生成:
[{"id":"1","title":"Ray","author":"Ray","thumb":"some source","views":"10000"}]
但我想生成一个像这样的json字符串:
[{"id":"1","title":"Ray","author":"Ray","image":{"cls":"image","thumb":"some source","views":"10000"}}]
有什么帮助吗?