exception 'ErrorException' with message 'Illegal string offset 'tax''
C'est l'erreur fatale je reçoiserreur fatale après un isset?
Log::error(print_r($pax_group , true));
Log::error(var_dump($pax_group));
if(isset($pax_group["otherdetail"]["tax"]["details"]["detail"][0]))
{
// I get the fatal error at the foreach line
foreach($pax_group["otherdetail"]["tax"]["details"]["detail"] as $one_tax)
{
$detail = new Otherdetail;
$detail->occ_paxs_id = $px->id;
$detail->code = $one_tax["code"];
$detail->amount = $one_tax["amt"];
$detail->B2Bamount = $one_tax["amt"];
$detail->save();
}
}
c'est la valeur que j'ai à l'intérieur otherdetail: <otherdetail>0</otherdetail>
Quelqu'un sait comment est-il possible que je passer par le isset quand je ne [ "taxe"] ["détails"] ["détail"] [0] à l'intérieur <otherdetail>0</otherdetail>
?
EDIT: Je suis maintenant capable de le reproduire. Voici ce que je reçois dans mon print_r et var_dump connecte
[2017-09-27 14:57:28] production.ERROR: Array
(
[cost] => 1033.60
[retail] => 1157.632
[wholesale] => 1157.632
[othertotal] => 0.00
[otherdetail] => 0
)
[] []
[2017-09-27 14:57:28] production.ERROR: [] []
[2017-09-27 14:57:28] production.ERROR: exception 'ErrorException' with message 'Illegal string offset 'tax'' in /home/*****************:1525
Plus xml:
<prices>
<total>
<cost>943.85</cost>
<wholesale>1021.6</wholesale>
<retail>1021.6</retail>
<othertotal>223.58</othertotal>
</total>
<paxgroup num="1">
<qty>2</qty>
<fromage>20</fromage>
<toage>120</toage>
<cost>471.93</cost>
<wholesale>510.80</wholesale>
<retail>510.80</retail>
<othertotal>111.79</othertotal>
<fare_type>PB</fare_type>
<components>
<AIR>
<cost>148.00</cost>
<retail>148</retail>
<wholesale>148</wholesale>
<othertotal>111.79</othertotal>
</AIR>
<HOT>
<cost>323.93</cost>
<retail>362.8016</retail>
<wholesale>362.8016</wholesale>
<othertotal>0.00</othertotal>
<otherdetail>0</otherdetail>
</HOT>
</components>
</paxgroup>
</prices>
JSON:
{"prices":{"total":{"cost":943.85,"wholesale":1021.6,"retail":1021.6,"othertotal":223.58},"paxgroup":[{"qty":"2","fromage":"20","toage":"120","cost":"471.93","wholesale":"510.80","retail":"510.80","othertotal":"111.79","fare_type":"PB","components":{"AIR":{"cost":"148.00","retail":148,"wholesale":148,"othertotal":"111.79"},"HOT":{"cost":"323.93","retail":362.8016,"wholesale":362.8016,"othertotal":"0.00","otherdetail":"0"}}}]}}
Je ne peux pas le reproduire. Y a-t-il d'autres codes que vous n'avez pas inclus? –
Faites un var_dump sur pax_group et postez le code: echo (var_dump ($ pax_group)); –
Moi aussi je ne peux pas le reproduire, mais je suis en train d'enregistrer le xml brut avant de l'enregistrer en db et c'est ce que j'avais dans otherdetail 0 otherdetail> –
user2942945