Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if this is what you are after, but you could use iexplode (a case insensitive version of explode, which i have used in the past when explode just won't cut it.). </p> <pre><code>&lt;?PHP function iexplode($delimiter, $string, $limit = false) { /* explode ( string $delimiter , string $string [, int $limit ] ) If limit is set and positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string . If the limit parameter is negative, all components except the last -limit are returned. If the limit parameter is zero, then this is treated as 1. Return Values If delimiter is an empty string (""), explode() will return FALSE. If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned. For any other limit , an array containing string will be returned. */ if (($delimiter === false) || ($delimiter == "")) { return false; } $first_token_at = stripos($string, $delimiter); if ($first_token_at === false) { if ($limit &lt; 0) { return array(); } return array( $string ); } $tokenlen = strlen($delimiter); $copypos = ($first_token_at == 0) ? $tokenlen : 0; $result = array(); $SCAN = strtoupper($string); $DELIM = strtoupper($delimiter); $work_array = $limit !== false ? explode($DELIM, $SCAN, $limit) : explode($DELIM, $SCAN); foreach ($work_array as $work) { $worklen = strlen($work); $this_chunk = substr($string, $copypos, $worklen); array_push($result, $this_chunk); $copypos += ($worklen + $tokenlen); } return $result; } function test_iexplode() { $testinput = "oranges and apples AND bananas And tomatoes aND artichokes"; $test1 = '$testoutput1 = iexplode("aNd",$testinput);'; $test2 = '$testoutput2 = iexplode("and",$testinput,1);'; $test3 = '$testoutput3 = iexplode("And",$testinput,2);'; $test4 = '$testoutput4 = iexplode("AND",$testinput,-1);'; eval($test1); eval($test2); eval($test3); eval($test4); echo var_export(compact(testinput, test1, testoutput1, test2, testoutput2, test3, testoutput3, test4, testoutput4), true); $controlinput = "oranges and apples and bananas and tomatoes and artichokes"; $test1 = '$testoutput1 = explode("and",$controlinput);'; $test2 = '$testoutput2 = explode("and",$controlinput,1);'; $test3 = '$testoutput3 = explode("and",$controlinput,2);'; $test4 = '$testoutput4 = explode("and",$controlinput,-1);'; eval($test1); eval($test2); eval($test3); eval($test4); echo var_export(compact(controlinput, test1, testoutput1, test2, testoutput2, test3, testoutput3, test4, testoutput4), true); } /* array( 'testinput' =&gt; 'oranges and apples AND bananas And tomatoes aND artichokes', 'test1' =&gt; '$testoutput1 = iexplode("aNd",$testinput);', 'testoutput1' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples ', 2 =&gt; ' bananas ', 3 =&gt; ' tomatoes ', 4 =&gt; ' artichokes' ), 'test2' =&gt; '$testoutput2 = iexplode("and",$testinput,1);', 'testoutput2' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples ', 2 =&gt; ' bananas ', 3 =&gt; ' tomatoes ', 4 =&gt; ' artichokes' ), 'test3' =&gt; '$testoutput3 = iexplode("And",$testinput,2);', 'testoutput3' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples ', 2 =&gt; ' bananas ', 3 =&gt; ' tomatoes ', 4 =&gt; ' artichokes' ), 'test4' =&gt; '$testoutput4 = iexplode("AND",$testinput,-1);', 'testoutput4' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples ', 2 =&gt; ' bananas ', 3 =&gt; ' tomatoes ', 4 =&gt; ' artichokes' ) ); array( 'controlinput' =&gt; 'oranges and apples and bananas and tomatoes and artichokes', 'test1' =&gt; '$testoutput1 = explode("and",$controlinput);', 'testoutput1' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples ', 2 =&gt; ' bananas ', 3 =&gt; ' tomatoes ', 4 =&gt; ' artichokes' ), 'test2' =&gt; '$testoutput2 = explode("and",$controlinput,1);', 'testoutput2' =&gt; array( 0 =&gt; 'oranges and apples and bananas and tomatoes and artichokes' ), 'test3' =&gt; '$testoutput3 = explode("and",$controlinput,2);', 'testoutput3' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples and bananas and tomatoes and artichokes' ), 'test4' =&gt; '$testoutput4 = explode("and",$controlinput,-1);', 'testoutput4' =&gt; array( 0 =&gt; 'oranges ', 1 =&gt; ' apples ', 2 =&gt; ' bananas ', 3 =&gt; ' tomatoes ' ) ); */ ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload