Eduardo Fuerte
asked on
Could you point a way to eliminate an array unexpected element?
Hi Experts
Could you point a way to eliminate an array unexpected element?
Accordingly to this picture (hard to see since I had to take a photo, the copy/ paste isn't allowed from the prodution server):
The 4th element (I don't know the reason appear like it:
How to eliminate it from the array?
Thanks in advance.
Could you point a way to eliminate an array unexpected element?
Accordingly to this picture (hard to see since I had to take a photo, the copy/ paste isn't allowed from the prodution server):
The 4th element (I don't know the reason appear like it:
[------7e1190133] =>
That is causing an error.How to eliminate it from the array?
Thanks in advance.
ASKER
Hi Ray
Really, I tryed before the way you pointed but since the array index is so weird and I can't be sure it's a constant value, I decided to reconstruct the array by using only the correct values, like:
Your solutions is good if the index is always [------7e119013]
Since I do't know from where tjis index comes, I prefer to reconstruct the array...
Really, I tryed before the way you pointed but since the array index is so weird and I can't be sure it's a constant value, I decided to reconstruct the array by using only the correct values, like:
$dados [x] = $params[x];
$dados [y] = $params[y];
..
$dados [n] = $params[n];
//Don't considering $params [------7e1190133] =>
// So, since $dados has only good values
$params = $dados;
Your solutions is good if the index is always [------7e119013]
Since I do't know from where tjis index comes, I prefer to reconstruct the array...
Well, with most things like this, the devil is in the details. Can you provide us more examples of the "bad" index? It would seem possible to write a regular expression that could eliminate any of a set of possible bad indexes if we could discern the "rules" about the bad index.
You can rebuild the array, and that may get you to the end of the problem today, but it's a potentially brittle solution. For example, does the code that generates this array get called anywhere else in the system? If so, those parts of the system may need to be changed, too. The problem could have a lot of tentacles, like an octopus.
The bigger question, of course, is where did this get injected. And how did the subsystem pass unit tests but fail in the deployed application?
You can rebuild the array, and that may get you to the end of the problem today, but it's a potentially brittle solution. For example, does the code that generates this array get called anywhere else in the system? If so, those parts of the system may need to be changed, too. The problem could have a lot of tentacles, like an octopus.
The bigger question, of course, is where did this get injected. And how did the subsystem pass unit tests but fail in the deployed application?
Can we see where the data is coming from?
What is the source of the data?
What is the source of the data?
ASKER
Hi
I'm still checking the code from where this array element came from...
I'm still checking the code from where this array element came from...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Since I had not found the cause of this array's symptom I think the remedy is ok.
Thanks!
Thanks!
If the key is "foo" and the array is $arr, you would use unset($arr['foo']);