Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/04/2020, 11:28
antonio_dsanchez
 
Fecha de Ingreso: abril-2015
Mensajes: 130
Antigüedad: 9 años, 1 mes
Puntos: 0
Buscar un string en un array en PHP llamando a una API

quiero buscar una cadena dentro de un array que me regresa una API

este es lo que me regresa la API

Código HTML:
[
{
    "id": "5a162db4-4443-4ee8-828a-372562230bf9",
    "supplyItemNumber": "PDH2OS001",
    "type": "Machine",
    "category": "Coolants & Lubricants",
    "priority": "Alto",
    "group": "Lubricants",
    "description": "",
    "customerUnitPrice": 0.00,
    "inventoryUnit": "Litre",
    "briefDescription": "",
    "accountId": null,
    "manufacturerCode": null,
    "supplierId": null,
    "manufacturerItemNumber": "",
    "manufacturerItemRevision": "",
    "manufacturerText": "",
    "createdDate": "2018-12-11T22:57:58Z",
    "createdById": "6e6a5c41-f62c-460b-96f4-fcab58381bbe",
    "modifiedDate": "2019-03-06T15:46:56Z",
    "modifiedById": "6e6a5c41-f62c-460b-96f4-fcab58381bbe",
    "taxCodeNumber": null,
    "maxQuantity": 0.00,
    "minQuantity": 0.00
},
{
    "id": "96d85b76-5231-4ce4-95fc-7fa9c915caab",
    "supplyItemNumber": "PDH2OS002",
    "type": "Machine",
    "category": "Coolants & Lubricants",
    "priority": "Alto",
    "group": "Lubricants",
    "description": "",
    "customerUnitPrice": 0.00,
    "inventoryUnit": "Litre",
    "briefDescription": "",
    "accountId": null,
    "manufacturerCode": null,
    "supplierId": null,
    "manufacturerItemNumber": "",
    "manufacturerItemRevision": "",
    "manufacturerText": "",
    "createdDate": "2018-12-11T22:57:58Z",
    "createdById": "6e6a5c41-f62c-460b-96f4-fcab58381bbe",
    "modifiedDate": "2019-03-06T15:46:45Z",
    "modifiedById": "6e6a5c41-f62c-460b-96f4-fcab58381bbe",
    "taxCodeNumber": null,
    "maxQuantity": 0.00,
    "minQuantity": 0.00
} ]
y este es mi codigo con el que lo busco

Código PHP:
Ver original
  1. var_export ($response);
  2. $indice = array_search($direccion,$response,false);
  3. echo "El número 5 está en el indice: " . $indice;

pero me regresa el siguiente error

Warning: array_search() expects parameter 2 to be array, string given in