如何在 Laravel 中返​​回唯一值

2024-05-08

这里我有这个示例数据,它根据类别产品返回,我需要限制重复值。

Raw JSON

[{
        "brand": {
            "id": "fe877b45-8620-453a-8805-63f0cbd80752",
            "name": "No Brand",
            "slug": "no-brand",
            "description": "null"
        },
        "options": [{
                "id": "324af955-1aa9-42ea-be6e-bb4e5623a97a",
                "parent_id": "null",
                "name": "Need Insurance?"
            },
            {
                "id": "73298c18-4ccc-4138-afa5-71d3d00dff9b",
                "parent_id": "null",
                "name": "Color",
                "slug": "color"
            }
        ],
        "rating": [],
        "tags": [{
            "id": "8a31ee4c-3302-4357-9686-bd4308bbf39f",
            "name": "options",
            "slug": "options",
            "photo": "null"
        }],
        "variations": [{
                "id": "3bf5aeb9-9da2-4fb1-a3d2-f89eb75839c3",
                "parent_id": "null",
                "name": "Ram",
                "slug": "ram",
                "photo": "null"
            },
            {
                "id": "e5c70766-a558-4539-b41f-77f72c819a7c",
                "parent_id": "null",
                "name": "cpu",
                "slug": "cpu",
                "photo": "null"
            },
            {
                "id": "e63ac831-f595-4889-83d2-a5be65734758",
                "parent_id": "null",
                "name": "Monitor",
                "slug": "monitor"
            }
        ]
    },
    {
        "brand": {
            "id": "fe877b45-8620-453a-8805-63f0cbd80752",
            "name": "No Brand",
            "slug": "no-brand",
            "description": null
        },
        "options": [{
            "id": "522da418-eb3f-43e9-9392-63c941842a52",
            "parent_id": null,
            "name": "Color",
            "slug": "color-3"
        }],
        "rating": [],
        "tags": [],
        "variations": [{
            "id": "8e9a26c5-2ee4-4d86-9244-a10596d67fea",
            "parent_id": null,
            "name": "cpu",
            "slug": "cpu-3",
            "photo": null
        }]
    }
]

样本数据

filters: [{,…}, {,…}]
    0: {,…}
        brand: {id: "fe877b45-8620-453a-8805-63f0cbd80752", name: "No Brand", slug: "no-brand", description: null,…}
        options: [{id: "324af955-1aa9-42ea-be6e-bb4e5623a97a", parent_id: null, name: "Need Insurance?",…},…]
            0: {id: "324af955-1aa9-42ea-be6e-bb4e5623a97a", parent_id: null, name: "Need Insurance?",…}
            1: {id: "73298c18-4ccc-4138-afa5-71d3d00dff9b", parent_id: null, name: "Color", slug: "color",…}
        rating: []
        tags: [{id: "8a31ee4c-3302-4357-9686-bd4308bbf39f", name: "options", slug: "options", photo: null,…},…]
        variations: [,…]
            0: {id: "3bf5aeb9-9da2-4fb1-a3d2-f89eb75839c3", parent_id: null, name: "Ram", slug: "ram", photo: null,…}
            1: {id: "e5c70766-a558-4539-b41f-77f72c819a7c", parent_id: null, name: "cpu", slug: "cpu", photo: null,…}
            2: {id: "e63ac831-f595-4889-83d2-a5be65734758", parent_id: null, name: "Monitor", slug: "monitor",…}
    1: {,…}
        brand: {id: "fe877b45-8620-453a-8805-63f0cbd80752", name: "No Brand", slug: "no-brand", description: null,…}
        options: [{id: "522da418-eb3f-43e9-9392-63c941842a52", parent_id: null, name: "Color", slug: "color-3",…}]
            0: {id: "522da418-eb3f-43e9-9392-63c941842a52", parent_id: null, name: "Color", slug: "color-3",…}
        rating: []
        tags: [,…]
        variations: [,…]
            0: {id: "8e9a26c5-2ee4-4d86-9244-a10596d67fea", parent_id: null, name: "cpu", slug: "cpu-3", photo: null,…}

解释

正如您所看到的,我的每个产品都有相同的数据字段,其中一些是相同的,例如options两种产品都有Color or in variations都有cpu or brand两者是相同的,在最终结果中我只需要 1Color and 1 cpu和 1 个品牌,因为它们是相同的。

code

这就是上面代码的返回方式

$data = [];
foreach($products as $i => $product) {
    $data[$i]['brand'] = $product->brand;
    $data[$i]['rating'] = $product->rating;
    $data[$i]['variations'] = $product->variations;
    $data[$i]['options'] = $product->options;
    $data[$i]['tags'] = $product->tags;
}

注:最终结果为merge of all products data into single array, but unique价值观。这就是我正在寻找的。

任何想法?

Update

最终结果的样本会是这样的

finalResult: [{,…}, {,…}]
    0: {,…}
        brand: {id: "fe877b45-8620-453a-8805-63f0cbd80752", name: "No Brand", slug: "no-brand", description: null,…}
            0: {id: "fe877b45-8620-453a-8805-63f0cbd80752", name: "No Brand", slug: "no-brand", description: null,…},…] // it was same in both products
        options: [{id: "324af955-1aa9-42ea-be6e-bb4e5623a97a", parent_id: null, name: "Need Insurance?",…},…]
            0: {id: "324af955-1aa9-42ea-be6e-bb4e5623a97a", parent_id: null, name: "Need Insurance?",…}
            1: {id: "73298c18-4ccc-4138-afa5-71d3d00dff9b", parent_id: null, name: "Color", slug: "color",…} // it was same in both products
        rating: []
        tags: [{id: "8a31ee4c-3302-4357-9686-bd4308bbf39f", name: "options", slug: "options", photo: null,…},…]
            0: {id: "8a31ee4c-3302-4357-9686-bd4308bbf39f", name: "options", slug: "options", photo: null,…}
            1: {id: "94ef99b6-ed2a-4eea-9248-e4775159eb58", name: "product", slug: "product", photo: null,…}
            2: {id: "378802b3-d13a-48c4-afa2-f9fed94d69ee", name: "werg", slug: "werg", photo: null, active: "yes",…} // added from another product
            3: {id: "f1380f50-af59-4f6a-8eca-d40689c1c1c1", name: "werwg", slug: "werwg", photo: null, active: "yes",…} // added from another product
        variations: [,…]
            0: {id: "3bf5aeb9-9da2-4fb1-a3d2-f89eb75839c3", parent_id: null, name: "Ram", slug: "ram", photo: null,…}
            1: {id: "e5c70766-a558-4539-b41f-77f72c819a7c", parent_id: null, name: "cpu", slug: "cpu", photo: null,…} // it was same in both products
            2: {id: "e63ac831-f595-4889-83d2-a5be65734758", parent_id: null, name: "Monitor", slug: "monitor",…}

Update 2

获取数据的子级

选项和变体都有子项(即Cpu => [Core i7, Core i3]) or color => ['red', 'black']所以我需要收集这些孩子的数据并将其放在父母的数据下。

Option model

public function options()
    {
        return $this->hasMany(Option::class);
    }

    public function children() {
        return $this->hasMany(Option::class,'parent_id','id') ;
    }

    public function parent()
    {
        return $this->belongsTo(Option::class,'parent_id');
    }

    public function isParent()
    {
        return !$this->parent_id ? true : false; // if parent_id is null => is a Parent Option
    }

Variant model

public function variants()
    {
        return $this->hasMany(Variant::class);
    }

    public function children() {
        return $this->hasMany(Variant::class,'parent_id','id') ;
    }

    public function parent()
    {
        return $this->belongsTo(Variant::class,'parent_id');
    }

    public function isParent()
    {
        return !$this->parent_id ? true : false; // if parent_id is null => is a Parent Variant
    }

注意:正如您可能了解的那样,父母和孩子之间的关系是由以下定义的parent_id column.

Sample data(包括所有数组及其子数组)

{
   "brands": [
      {
         "id": "fe877b45-8620-453a-8805-63f0cbd80752",
         "name": "no brand",
         "slug": "no-brand",
         "description": null,
         "photo": null,
         "created_at": "2020-07-15 11:35:18",
         "updated_at": "2020-07-15 11:35:18"
      }
   ],
   "options": [
      {
         "id": "324af955-1aa9-42ea-be6e-bb4e5623a97a",
         "parent_id": null,
         "name": "need insurance?",
         "slug": "need-insurance",
         "photo": null,
         "type": "radio",
         "active": "yes",
         "created_at": "2020-07-17 11:28:09",
         "updated_at": "2020-07-17 11:28:09",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "option_id": "324af955-1aa9-42ea-be6e-bb4e5623a97a"
         },
         "children": [
            {
               "id": "44afca9e-abf1-4a7a-9c46-d96d8127c2af",
               "parent_id": "324af955-1aa9-42ea-be6e-bb4e5623a97a",
               "name": "No",
               "slug": "no",
               "photo": null,
               "type": "radio",
               "active": "yes",
               "created_at": "2020-07-17 11:28:09",
               "updated_at": "2020-07-17 11:28:09"
            }
         ]
      },
      {
         "id": "73298c18-4ccc-4138-afa5-71d3d00dff9b",
         "parent_id": null,
         "name": "color",
         "slug": "color",
         "photo": null,
         "type": "dropdown",
         "active": "yes",
         "created_at": "2020-07-17 11:27:41",
         "updated_at": "2020-07-17 11:27:41",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "option_id": "73298c18-4ccc-4138-afa5-71d3d00dff9b"
         },
         "children": [
            {
               "id": "29b62f35-52a2-4a8b-ac8f-7e70e065488a",
               "parent_id": "73298c18-4ccc-4138-afa5-71d3d00dff9b",
               "name": "Black",
               "slug": "black",
               "photo": null,
               "type": "dropdown",
               "active": "yes",
               "created_at": "2020-07-17 11:27:41",
               "updated_at": "2020-07-17 11:27:41"
            },
            {
               "id": "4aa2d899-f1cc-4000-95e6-997d28dc51fc",
               "parent_id": "73298c18-4ccc-4138-afa5-71d3d00dff9b",
               "name": "Red",
               "slug": "red",
               "photo": null,
               "type": "dropdown",
               "active": "yes",
               "created_at": "2020-07-17 11:27:41",
               "updated_at": "2020-07-17 11:27:41"
            },
            {
               "id": "5f9de5bc-e966-48f3-b78c-de709dba86b5",
               "parent_id": "73298c18-4ccc-4138-afa5-71d3d00dff9b",
               "name": "Gray",
               "slug": "gray",
               "photo": null,
               "type": "dropdown",
               "active": "yes",
               "created_at": "2020-07-17 11:27:41",
               "updated_at": "2020-07-17 11:27:41"
            },
            {
               "id": "f248d6ab-1b88-4ea4-8d6a-62fe271bfa8a",
               "parent_id": "73298c18-4ccc-4138-afa5-71d3d00dff9b",
               "name": "White",
               "slug": "white",
               "photo": null,
               "type": "dropdown",
               "active": "yes",
               "created_at": "2020-07-17 11:27:41",
               "updated_at": "2020-07-17 11:27:41"
            }
         ]
      },
      {
         "id": "522da418-eb3f-43e9-9392-63c941842a52",
         "parent_id": null,
         "name": "color",
         "slug": "color-3",
         "photo": null,
         "type": "radio",
         "active": "yes",
         "created_at": "2020-07-17 12:20:46",
         "updated_at": "2020-07-17 12:20:46",
         "pivot": {
            "product_id": "a8bb27c8-e968-4317-b4d2-8e5cd6049ff8",
            "option_id": "522da418-eb3f-43e9-9392-63c941842a52"
         },
         "children": [
            {
               "id": "84135f25-690b-407b-8c98-e7526429a594",
               "parent_id": "522da418-eb3f-43e9-9392-63c941842a52",
               "name": "Red",
               "slug": "red-3",
               "photo": null,
               "type": "radio",
               "active": "yes",
               "created_at": "2020-07-17 12:20:46",
               "updated_at": "2020-07-17 12:20:46"
            },
            {
               "id": "9d1f0d9c-272a-4e96-ac0a-aeac869bfc30",
               "parent_id": "522da418-eb3f-43e9-9392-63c941842a52",
               "name": "Yellow",
               "slug": "yellow-2",
               "photo": null,
               "type": "radio",
               "active": "yes",
               "created_at": "2020-07-17 12:20:46",
               "updated_at": "2020-07-17 12:20:46"
            }
         ]
      }
   ],
   "ratings": [
      "4.5",
      "4.0"
   ],
   "tags": [
      {
         "id": "8a31ee4c-3302-4357-9686-bd4308bbf39f",
         "name": "options",
         "slug": "options",
         "photo": null,
         "active": "yes",
         "created_at": "2020-07-17 11:29:47",
         "updated_at": "2020-07-17 11:29:47",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "tag_id": "8a31ee4c-3302-4357-9686-bd4308bbf39f"
         }
      },
      {
         "id": "94ef99b6-ed2a-4eea-9248-e4775159eb58",
         "name": "product",
         "slug": "product",
         "photo": null,
         "active": "yes",
         "created_at": "2020-07-17 11:29:47",
         "updated_at": "2020-07-17 11:29:47",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "tag_id": "94ef99b6-ed2a-4eea-9248-e4775159eb58"
         }
      },
      {
         "id": "378802b3-d13a-48c4-afa2-f9fed94d69ee",
         "name": "werg",
         "slug": "werg",
         "photo": null,
         "active": "yes",
         "created_at": "2020-07-15 11:53:13",
         "updated_at": "2020-07-15 11:53:13",
         "pivot": {
            "product_id": "a8bb27c8-e968-4317-b4d2-8e5cd6049ff8",
            "tag_id": "378802b3-d13a-48c4-afa2-f9fed94d69ee"
         }
      },
      {
         "id": "f1380f50-af59-4f6a-8eca-d40689c1c1c1",
         "name": "werwg",
         "slug": "werwg",
         "photo": null,
         "active": "yes",
         "created_at": "2020-07-15 11:53:13",
         "updated_at": "2020-07-15 11:53:13",
         "pivot": {
            "product_id": "a8bb27c8-e968-4317-b4d2-8e5cd6049ff8",
            "tag_id": "f1380f50-af59-4f6a-8eca-d40689c1c1c1"
         }
      }
   ],
   "variations": [
      {
         "id": "3bf5aeb9-9da2-4fb1-a3d2-f89eb75839c3",
         "parent_id": null,
         "name": "ram",
         "slug": "ram",
         "photo": null,
         "type": "input",
         "active": "yes",
         "created_at": "2020-07-17 11:27:05",
         "updated_at": "2020-07-17 11:27:05",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "variant_id": "3bf5aeb9-9da2-4fb1-a3d2-f89eb75839c3"
         },
         "children": [
            {
               "id": "5687d6a8-12df-41b2-bf2f-b822faae8af0",
               "parent_id": "3bf5aeb9-9da2-4fb1-a3d2-f89eb75839c3",
               "name": "4 Gig",
               "slug": "4 Gig",
               "photo": null,
               "type": "input",
               "active": "yes",
               "created_at": "2020-07-17 11:27:05",
               "updated_at": "2020-07-17 11:27:05"
            }
         ]
      },
      {
         "id": "e5c70766-a558-4539-b41f-77f72c819a7c",
         "parent_id": null,
         "name": "cpu",
         "slug": "cpu",
         "photo": null,
         "type": "input",
         "active": "yes",
         "created_at": "2020-07-17 11:26:58",
         "updated_at": "2020-07-17 11:26:58",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "variant_id": "e5c70766-a558-4539-b41f-77f72c819a7c"
         },
         "children": [
            {
               "id": "83003a24-cc69-4305-8d3a-e99da91d3354",
               "parent_id": "e5c70766-a558-4539-b41f-77f72c819a7c",
               "name": "Core i7",
               "slug": "Core i7",
               "photo": null,
               "type": "input",
               "active": "yes",
               "created_at": "2020-07-17 11:26:58",
               "updated_at": "2020-07-17 11:26:58"
            }
         ]
      },
      {
         "id": "e63ac831-f595-4889-83d2-a5be65734758",
         "parent_id": null,
         "name": "monitor",
         "slug": "monitor",
         "photo": null,
         "type": "input",
         "active": "yes",
         "created_at": "2020-07-17 11:27:21",
         "updated_at": "2020-07-17 11:27:21",
         "pivot": {
            "product_id": "293c0369-04a7-4330-bb98-ede0bcf10f8d",
            "variant_id": "e63ac831-f595-4889-83d2-a5be65734758"
         },
         "children": [
            {
               "id": "816e1fab-24eb-49e9-9b3a-d4b4cce16cdf",
               "parent_id": "e63ac831-f595-4889-83d2-a5be65734758",
               "name": "14\"",
               "slug": "14\"",
               "photo": null,
               "type": "input",
               "active": "yes",
               "created_at": "2020-07-17 11:27:21",
               "updated_at": "2020-07-17 11:27:21"
            }
         ]
      },
      {
         "id": "8e9a26c5-2ee4-4d86-9244-a10596d67fea",
         "parent_id": null,
         "name": "cpu",
         "slug": "cpu-3",
         "photo": null,
         "type": "input",
         "active": "yes",
         "created_at": "2020-07-17 12:20:56",
         "updated_at": "2020-07-17 12:20:56",
         "pivot": {
            "product_id": "a8bb27c8-e968-4317-b4d2-8e5cd6049ff8",
            "variant_id": "8e9a26c5-2ee4-4d86-9244-a10596d67fea"
         },
         "children": [
            {
               "id": "50857808-106e-4ae0-8c02-a54761e6dac7",
               "parent_id": "8e9a26c5-2ee4-4d86-9244-a10596d67fea",
               "name": "Core i3",
               "slug": "Core i3-2",
               "photo": null,
               "type": "input",
               "active": "yes",
               "created_at": "2020-07-17 12:20:56",
               "updated_at": "2020-07-17 12:20:56"
            }
         ]
      }
   ]
}

您可以使用reduce 在一次数据迭代中实现您想要的效果,如下所示:

$variations = [];

$result = array_reduce($filters, function ($result, $filter) use ($variations) {
    $filter['brand']['name'] = strtolower($filter['brand']['name']);
    if ($result['brands']->where('name', $filter['brand']['name'])->isEmpty()) {
        $result['brands']->push($filter['brand']);
    }

    foreach ($filter['options'] as $option) {
        $option['name'] = strtolower($option['name']);

        if ($result['options']->where('name', $option['name'])->isEmpty()) {
            $result['options']->push($option);
        }
    }

    if (isset($filter['rating']['id'])) {
        if ($result['ratings']->where('id', $filter['rating']['id'])->isEmpty()) {
            $result['ratings']->push($filter['rating']);
        }
    }

    foreach ($filter['tags'] as $tag) {
        $tag['name'] = strtolower($tag['name']);

        if ($result['tags']->where('name', $tag['name'])->isEmpty()) {
            $result['tags']->push($tag);
        }
    }

    foreach ($filter['variations'] as $variation) {
        $variation['name'] = strtolower($variation['name']);
        $variationName = $variation['name'];         
        $children = collect($variation['children'])->pluck('name');

        if ($result['variations']->where('name', $variation['name'])->isEmpty()) {
            $result['variations']->push($variation);
            $variations[$variationName] = $children;

        } else {
            $different = $variations[$variationName]->diff($children);
            
            if ($different->isNotEmpty()) {
               $result['variations']->push($variation);
               foreach ($different as $childName) {
                   $variations[$variationName]->push($childName);
               }  
            }
        }
    }

    return $result;

}, collect([
    'brands' => collect(),
    'options' => collect(),
    'ratings' => collect(),
    'tags' => collect(),
    'variations' => collect()
]));

如果需要将结果作为数组,可以使用集合的 toArray 方法:

    $result->toArray();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Laravel 中返​​回唯一值 的相关文章

  • 使用“INSERT ... ON DUPLICATE KEY UPDATE”插入多条记录

    我的表结构 table marks 我的目标 我想用条件插入或更新多条记录 我目前正在通过此查询进行检查 第一步 SELECT FROM marks WHERE student 115 AND param 1 第二步 if records
  • PHP 正则表达式匹配字符串的最后一次出现

    我的字符串是 text1 A373R12345 我想找到该字符串最后出现的非数字数字 所以我使用这个正则表达式 0 9 然后我得到这个结果 1 A373 2 12345 但我的预期结果是 1 A373R 它有 R 2 12345 另一个例子
  • 获取今天的科普特日期

    我正在寻找获取今天的科普特日期与任何代码类型类似php or javascript在我的网站标题中显示科普特日期 我需要阿拉伯语或英语版本 我试图找到它 但没有找到类似的英文内容 参考 http www copticchurch net e
  • 如何仅删除页面的自动段落格式,而不删除帖子的自动段落格式(WordPress)

    我已经熟悉这个在 WordPress 中删除自动段落格式的小技巧 remove filter the content wpautop remove filter the excerpt wpautop 但是添加这个函数 php删除整个网站的
  • file_get_contents 大文件上传

    我正在尝试使用 fsockopen 上传 2GB 以上的大文件 但 file get content 出现以下错误 我无法在内存中存储大文件 我需要分块发送数据 但不知道如何执行此操作 请问有人可以指导我吗 致命错误 允许的内存大小 134
  • Laravel - 急切加载 Eloquent 模型的方法(而不是关系)

    就像我们可以急切加载 Eloquent 模型的关系一样 有没有办法急切加载不是 Eloquent 模型的关系方法的方法 例如 我有一个 Eloquent 模型GradeReport它有以下方法 public function totalSc
  • div 中的文本字符有限,添加“阅读更多”链接并在单击链接时显示所有字符

    我有一个 div 里面有文本 使用 PHP 和 MySQL 显示 结构如下 div class description p Here is a lot of text p div 我想在 p 标签内的文本超过 100 个字符时显示 阅读更多
  • Ajax文件上传

    我想使用 Ajax 和 php 上传文件 我有一个表格
  • 从 php 执行 bash 脚本并立即输出回网页

    我有一组 bash 和 Perl 脚本 开发在 Linux Box 上部署所需的目录结构 可选 从svn导出代码 从这个源构建一个包 这在终端上运行良好 现在 我的客户请求此流程的 Web 界面 例如 某些页面上的 创建新包 按钮将一一调用
  • PHP-docker容器中的环境变量

    我想在我的 docker 容器中显示一个环境变量 PHP 脚本如下所示 我使用 OpenShift 来启动容器 PHP 容器显示 env is 现在我更改容器的 dc 配置 oc env dc envar USER Pieter deplo
  • 如何在php中使用一张图像绘制形状

    我需要使用图像的一部分来创建帧图像 例如 用户将从后端上传图像片段 现在我需要根据前端用户的要求在前端创建一个框架 用户将选择框架的高度和宽度 然后他将选择该图像片段 如下所示 我没有办法做到这一点 我尝试通过 css 和 html can
  • json_encode 返回 NULL?

    由于某种原因 项目 描述 返回NULL使用以下代码 这是我的数据库的架构 CREATE TABLE staff id int 11 NOT NULL AUTO INCREMENT name longtext COLL
  • 付款成功后保存到数据库(paypal)

    我试图找出在客户使用 paypal 支付商品费用后将数据 之前以表单提交 保存到数据库的最佳方法 沿着这个过程的一些事情 1 在实际网站上填写表格 gt 2 登录 Paypal gt 3 立即付款 PayPal gt 4 数据已插入数据库
  • php oracle客户端oci8安装出现什么问题

    我尝试了安装 PHP Oracle 客户端的所有过程 1 我安装了客户端版本8和32位 2 我在php ini中取消了oci的注释 3 重新启动Wamp 4 不确定是否真的安装 但我在 php ini 中得到了引用 5 但仍然无法连接 泰汉
  • 使用 yum 和 pear 安装 php-soap 均失败

    我正在尝试在 Centos 6 4 服务器上安装 PHP 的 SOAP 扩展 我对包管理器 从 CLI 安装包并在 PHP 中配置它们相当不熟悉 我相当有能力管理 php ini 和其他 PHP 配置文件 soap ini 等 我尝试使用以
  • PHP Intl 扩展线程安全吗?

    我一直在阅读有关 PHP 中的语言环境的内容 看起来setlocale 线程有问题 我对线程不太熟悉 文档提到它不是线程安全的 我想让我的项目能够处理某些数字格式 并且 Intl 扩展似乎很有趣 http php net manual en
  • PHP 中的encodeURI() ?

    PHP 中是否有一些不编码的encodeURI 函数 我现在用这个 function encodeURI url http php net manual en function rawurlencode php https develope
  • 为什么这评估为 true

    为什么这评估结果为真
  • 禁用 WooCommerce 手动/编辑订单的电子邮件通知

    需要 WooCommerce 专业知识 我需要禁用手动创建的订单的电子邮件通知 我必须使用处理状态 由于处理订单状态的自定义挂钩 我无法创建自定义状态 理想情况下 手动订单页面中可以勾选一个复选框 勾选后 它将禁止在每种状态下向客户发送电子
  • 如何将图像从 Android 应用程序上传到网络服务器的特定文件夹中

    如何将图像从 android 移动到 Web 服务器上的指定文件夹 这是我的安卓代码 package com example bitmaptest import java io ByteArrayOutputStream import ja

随机推荐