User Tools

Site Tools


uphp:functions:explode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
uphp:functions:explode [2017/05/09 10:01]
jeff
uphp:functions:explode [2021/09/13 05:57] (current)
Line 24: Line 24:
 <html><b><span style="color:blue">$delimiter<span style="color:black"></b></html>:  Character to use for separation <html><b><span style="color:blue">$delimiter<span style="color:black"></b></html>:  Character to use for separation
  
-====Return Value====+====Return Values====
  
 <html><b><span style="color:green">Array<span style="color:black"></b></html> of elements <html><b><span style="color:green">Array<span style="color:black"></b></html> of elements
Line 46: Line 46:
 (string) [3] => four (string) [3] => four
  
 +?></pre>
 +</code>
 +
 +Note that if only one element is present (without the separator character) then a value of -1 will be returned.  This differs from the PHP implementation.  
 +
 +<code php>
 +<pre><?
 +  $mylist="one";
 +  $myarray=explode($mylist,",");
 +  
 +  // the fix for a single parameter is to use is_array
 +  if (!is_array($myarray)) {
 +    $myarray=array($mylist);
 +  }
 +  print_r($myarray)
 +?></pre>
 </code> </code>
  
uphp/functions/explode.1494324070.txt.gz · Last modified: 2021/09/13 05:56 (external edit)