function valueToString($value, $indent = 4) { if (is_numeric($value)) { $value = $value; } else { if (is_bool($value)) { $value = $value ? 'true' : 'false'; } else { if (is_null($value)) { $value = 'null'; } else { if (is_string($value) && 0 !== strpos($value, 'new \\') && 0 !== strpos($value, '$scopeValues[') && 0 !== strpos($value, 'array(') && 0 !== strpos($value, '$this')) { $value = '"' . str_replace('"', '\\"', $value) . '"'; } else { if (is_array($value)) { $code = 'array(' . PHP_EOL; foreach ($value as $key => $val) { $code .= str_repeat(' ', $indent + 1) . valueToString($key) . ' => ' . valueToString($val, $indent + 1) . ',' . PHP_EOL; } $value = $code . str_repeat(' ', $indent) . ')'; } } } } } return $value; }
function parseTextAndComposePerson($hc, $nombreCarrion, $curl_exec) { // identificar y extraer seccion de interes $entireString = obtenerTablaQueRodeaOcurrenciaDeCadena($curl_exec, "DATOS PERSONALES"); $response = simplificarHtml($entireString); $xmlArray = xmlStringToArray($response); $person = array(); $person['hc'] = $hc; $person['nombre'] = valueToString($xmlArray['tr'][1]['td'][1]['B']); $person['fecha_nacimiento'] = valueToString($xmlArray['tr'][2]['td'][1]); $person['dni'] = valueToString($xmlArray['tr'][2]['td'][3]); $person['tipo_asegurado'] = valueToString($xmlArray['tr'][3]['td'][1]); $person['codigo_asegurado'] = valueToString($xmlArray['tr'][3]['td'][3]); $person['tipo_seguro'] = valueToString($xmlArray['tr'][4]['td'][3]); $person['centro_asistencial'] = valueToString($xmlArray['tr'][6]['td'][1]['b']); $person['afiliado_desde'] = valueToString($xmlArray['tr'][6]['td'][3]['b']); $person['direccion'] = valueToString($xmlArray['tr'][7]['td'][1]); $person['afiliado_hasta'] = valueToString($xmlArray['tr'][7]['td'][3]['b']); $person['centro_afiliacion'] = valueToString($xmlArray['tr'][8]['td'][1]); $person['nombre_hc_carrion'] = $nombreCarrion; return $person; }