0
Well, I have the following situation, I would need to check if the term exists (name of the fruits) if to delete the array that is matching the values (name of the fruit and code)
Example: When searching for the term pineapple do this
[0] => Array
(
[0] => maça
[1] => 1256
)
[1] => Array
(
[0] => abacaxi
[1] => 1234
)
[2] => Array
(
[0] => pera
[1] => 235
)
turn this around
[0] => Array
(
[0] => maça
[1] => 1256
)
[1] => Array
(
[0] => pera
[1] => 235
)
I couldn’t make it work with multidimensional array! Thank you all.
Thank you my expensive worked super well!
– Caio Lourençon
Hello, implementing in my project, I could notice that the first solution does not work with variables containing the search value, just by typing the string directly, you know the reason?
– Caio Lourençon
@Caiolourençon, you can put an example of the problem you mentioned so I can analyze it. It can be a link to a text file or an online sandbox. Because both examples use the same code as a base
in_array()
.– Augusto Vasques
edited, please check!
– Caio Lourençon
@Caiolourençon a variable
$val_busca
not declared within the scope of callback. Simply declare as global within callbackglobal $val_busca;
See example working: https://repl.it/repls/LuxuriousNeatExpertise– Augusto Vasques
I’m going to reverse the question, because the issue of the question has turned my answer into something meaningless.
– Augusto Vasques
congratulations, working perfectly as needed.
– Caio Lourençon
If you want to add this implementation in your solution comment, you’d also like it, because I think people will use variables to search.
– Caio Lourençon
@Caiolourençon I appreciate the suggestion, but I will decline because it leaves the original focus of the question and after answered the format of the site does not allow the change of scope of the question, so I reversed it, and also does not allow issues divergent from the original question. In the case I presented the solution out of courtesy, but correct guidance would be to ask a new question and lynch this as context.
– Augusto Vasques
goes there my dear I return the courtesy, https://answall.com/questions/448152/fu%C3%A7%C3%a3o-para-encontra-e-remover-termo-no-array-n%C3%a3o-funciona-com-variav%C3%a9l
– Caio Lourençon