Tengo este Array
Array
(
[0] => Array
(
[0] => Array
(
[data] => 2017<br>Condenser<br>Buick Verano
)
[1] => Array
(
[description] => COMPLETE COOLING (RAD/CON/FAN)
)
[2] => Array
(
[part_grade] => A
)
[3] => Array
(
[stock] => AA0818
)
[4] => Array
(
[us_price] => $450
)
[5] => Array
(
[dealer_info] => Auto Alex USA-CA(Sun-Valley) Request_Quote 818-504-7600 Request_Insurance_Quote
)
[6] => Array
(
[dist_mile] => 2344
)
)
[1] => Array
(
[0] => Array
(
[data] => 2013<br>Condenser<br>Cadillac XTS
)
[1] => Array
(
[description] => WTH RAD AND FAN ASSM,8-12,000-44K
)
[2] => Array
(
[part_grade] => A
)
[3] => Array
(
[stock] => 217563
)
[4] => Array
(
[us_price] => $400.01
)
[5] => Array
(
[dealer_info] => Miami Parts USA-FL(Opa-Locka) Request_Quote 1-800-644-4788 Request_Insurance_Quote
)
[6] => Array
(
[dist_mile] => 9
)
)
Pero este no me sirve y quisiera convertirlo como el siguiente, lo he intentado ya y no lo consigo, me gustaria dejarlo de este modo.
Array
(
[0] => Array
(
[data] => 2017<br>Condenser<br>Buick Verano,
[description] => COMPLETE COOLING (RAD/CON/FAN),
[part_grade] => A,
[stock] => AA0818,
[us_price] => $450,
[dealer_info] => Auto Alex USA-CA(Sun-Valley) Request_Quote 818-504-7600 Request_Insurance_Quote
,
[dist_mile] => 2344
)
[1] => Array
(
[data] => 2013<br>Condenser<br>Cadillac XTS,
[description] => WTH RAD AND FAN ASSM,8-12,000-44K,
[part_grade] => A,
[stock] => 217563,
[us_price] => $400.01,
[dealer_info] => Miami Parts USA-FL(Opa-Locka) Request_Quote 1-800-644-4788 Request_Insurance_Quote
,
[dist_mile] => 9
)
Aqui esta el codigo de la funcion que genera el array
public function getResults(Request $request)
{
$params = array(
"userDate" => $request->userDate,
"userModel" => $request->userModel,
"userPart" => $request->userPart,
"userLocation" => $request->userLocation,
"userPreference" => $request->userPreference,
"userZip" => $request->userZip,
"userVIN" => "",
"svZip" => "y",
"userPage" => "1",
"userInterchange" => $request->userInterchange,
"userDate2" => "Ending Year",
"userSearch" => "int",
"Search Car Part Inventory.x" => "33",
"Search Car Part Inventory.y" => "10",
);
// Send a GET request to: http://www.foo.com/bar
$response = Curl::to('http://car-part.com/cgi-bin/search.cgi')
->withContentType('application/x-www-form-urlencoded')
->withData($params)
->post();
if(stripos($response, "dummyVar")) {
echo "contiene";
} else {
if (stripos($response, "dbPart") && stripos($response, "userInterchange=")) {
$index = stripos($response, "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">");
$response = substr($response, $index);
$index = stripos($response, "</table>");
$response = substr($response, 0, $index + 8);
$index = stripos($response, "</tr>");
$response = substr($response, $index + 5);
$index = strripos($response, "<tr>");
$response = substr($response, 0, $index);
$response = str_replace("<tr>", "", $response);
$response = str_replace("<td>", "", $response);
$response = str_replace("<td align=center>", "", $response);
$response = str_replace("<td align=center nowrap>", "", $response);
$response = explode("</tr>", $response);
$temp = array();
foreach ($response as $key => $value) {
# code...
$value = explode("</td>", $value);
array_pop($value);
array_push($temp, $value);
}
$response = array();
for ($i=0; $i < count($temp); $i++) {
$arr = array();
$labels = ['data', 'description', 'part_grade', 'stock', 'us_price', 'dealer_info', 'dist_mile'];
# code...
for ($j=0; $j < count($temp[$i]); $j++) {
# code...
array_push($arr, [$labels[$j] => $temp[$i][$j]]);
}
array_push($response, $arr);
}
print_r($response);
} else {
return response()->json(['statusCode' => 404, 'statusText' => "Not Found", 'data' => null], 404);
}
}
}
$response
es el array resultante? ¿Qué hay, o mejor dicho, cómo queda$temp
después de llenarlo? No logro ver su estructura, porque no sé qué llegó desde elCurl
...