in Education by
How can I change the strpos to make it non case sensitive. The reason is if the product->name is MadBike and the search term is bike it will not echo me the link. My main concern is the speed of the code. <?php $xml = simplexml_load_file('test.xml'); $searchterm = "bike"; foreach ($xml->product as $product) { if (strpos($product->name, $searchterm) !== false ) { echo $product->link; } } ?> JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You're looking for stripos() If that isn't available to you, then just call strtolower() on both strings first. EDIT: stripos() won't work if you want to find a substring with diacritical sign. For example: stripos("Leży Jerzy na wieży i nie wierzy, że na wieży leży dużo JEŻY","jeży"); returns false, but it should return int(68).

Related questions

0 votes
    How can I change the strpos to make it non case sensitive. The reason is if the product->name is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    How can I change the strpos to make it non case sensitive. The reason is if the product->name is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    In Laravel, there is a function return back();, which returns the user to the previous page. Is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I have a script which loops over tables and fields doing a find and replace. The script takes around ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    Wordpress site. I want jquery or php, or any easy solution that will grab div from div id=content ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I am struggling to figure out how to specify a MOTO payment with Stripe API and PHP. I believe I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I have a table structure like this : subscribers with attributes: id, status I want to have a way ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm using the cacheCounter in CakePHP, which increments a counter for related fields. Example, I have a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm using the cacheCounter in CakePHP, which increments a counter for related fields. Example, I have a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I am aware that I can use array_unique(array_merge($a,$b)); to merge two arrays and then remove ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    Recently I asked a question regarding preg_match_all with php, and i got the perfect solution as expected ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
...