【发布时间】:2019-12-04 16:40:00
【问题描述】:
我希望我的 json 以 { 开头,但如果使用 json_encode 它会被转换为字符串,我在 ubuntu 上使用 php7.1 并使用 magento 2.3
这就是我用下面的代码得到的,我不想要'['
[
{
"success": "true",
"data": {
"mainimages": [
{
这是我的代码
$response = array(
array(
"success" => "true",
"data" => $alldata,
"newarrivalheading" => "NEW ARRIVALS",
"instagramheading" => "CELEBS IN LULU",
"specialpriceheading" => "SPECIAL PRICES",
"editorwishlistheading" => "EDITOR'S WISHLIST",
"stylehighlightheading" => "STYLE HIGHLIGHTS",
"styletagline" => "#Looks to swipe right",
"newarrivalindex" => 3,
"instagramindex" => 9,
"editorwishlistviewall" => "",
"sliderimage" => $sliderimage
)
);
return $response;
这就是我想要的
{
"success": "true",
"data": {
"mainimages": [
{
【问题讨论】:
-
太棒了,
json_encode($response[0])?或者干脆去掉外面的array()? -
您需要养成accepting answers 的习惯,它可以帮助您解决问题。您将获得积分,并鼓励其他人帮助您。
-
@Jay Blanchard 我仍然面临问题,所以一旦解决,我会接受答案。
标签: php arrays json php-7.1 magento-2.3