Undefined Index with existing variables [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
I know that with this error the variable doesn't exist in the array. Weirdly when I check the array, it does exists...... Am I blind? Am I missing something?
Undefined index: uuid on line 141
foreach($orderDetails->line_items as $orderLineItem) {
foreach($returnLineItems as $itemKey => $value){
if($orderLineItem->uuid == $returnLineItems[$itemKey]['uuid']) { //Line 141
}
}
}
Although this is an object:
dd($orderLineItem->uuid) => 236cb65b-a602-4422-a11a-803bd7dbf05d
The array:
dd($returnLineItems[$itemKey]['uuid'] => 236cb65b-a602-4422-a11a-803bd7dbf05d
Upon Comment request the DD of the entire

Ok after two hours I found it...
I was regenerating $returnLineItems in the foreach loop, causing the array to miss UUID.
Thanks for helping all!

Related

Get Value of array with multiple values [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
i know that has to be a trivial one. Can please somebody tell me how only to get the value of skills? how can i access it?
Appreciate.
You have different options to choose from:
In plain PHP you can do:
$skills = array_map(function($entry) {
return $entry->skills;
}, $arr);
With Laravel helpers you can do:
Arr::pluck($arr, 'skills');
Your data looks like models so in that case, you might be able to do this as well:
YourModel::get()->pluck('skills'); //or
$yourCollection->pluck('skills');

increment object name with numbers in a loop [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am having trouble to increment the name of an object within a loop but the following doesn't not seem to work
I need to increment $serie1->addPoint to $serie2->addPoint, $serie3->addPoint etc..
$i = 1;
foreach ($users as $agent) {
$serie{$i}->addPoint...
$i +=1;
}
I get an error Notice: Undefined variable: serie in
I also tried $serie.$i->addPoint... but that produced an error as well Fatal error: Call to a member function addPoint().
However, it does work if I manually assign the increments like so $serie1->addPoint etc..
It cannot be : $serie{$i}
It should be: ${'serie'.$i}
A short Demo

How to deal with "Undefined index: " [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
if(!isset($aProdcut[$eachYear][$store][$base])){
$aProdcut[$eachYear][$store][$base] = 0;
}
$aProduct[$eachYear][$store][$base] += $row['total_price'];
Undefined index: MARC. MARC is from $base.
Who can give me some hints?
You have a typo there $aProdcut vs $aProduct
The code should not result in undefined index if you have an $aProduct variable, which is an array and has an index value of $eachYear, which is, in turn another array, which has an index value of $store, since, in that case
isset($aProdcut[$eachYear][$store])
is true. If that is true and it does not have a $base index value, then it is created and initialized with 0. Later, when you use it, it will surely exist. So, the issue is probably that $aProduct[$eachYear] does not exist or $aProduct[$eachYear][$store] is not set. Make sure that everything exists, not just the innermost index and then the problem will be probably fixed. If the problem still persists, then you should check whether some other things are causing it, like multi-threading.

Php help find where is syntax error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes===".$card['id']."") as $kat){
echo (kat['id_categories']);
}
table cols and values are all matched, something is wrong in this part of code
I tried adding $ before kat and using only one "=", sill doesnt work
NEW LINK
http://pastebin.com/RPK7vEaJ
this
where id_kartes===".$card['id']."
would be
where id_kartes=".$card['id']."
and missing $
echo $kat['id_categories'];
so full code :-
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes='".$card['id']."'") as $kat){
echo $kat['id_categories'];
}
best practice if you store your query result in a variable and loop over this variable.
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)

How would you properly write this statement? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
New PHP programmer here. Need some syntax help.
Like I know what im trying to do, here, check if that session variable is set and if its a certain string value, but the "(" you need for isset is messing the syntax up. I can't find the help im looking for via google for what is really a very simple syntax question, so I had to come here.
if (isset($_SESSION['IsValid'] AND $_SESSION['IsValid']=="Yes")) {
}else{
}
Typos:
if (isset($_SESSION['IsValid']) AND $_SESSION['IsValid']=="Yes") {
^---missing ^---only one ) here
isset() is a function and checks a SINGLE variable if it "exists". You're trying to isset() the result of your AND operation, which is illegal syntax.
if( isset($_SESSION['IsValid']) && $_SESSION['IsValid'] == "Yes" ) {

Categories