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 Both sides next revision
uphp:functions:explode [2017/05/11 22:47]
jeff
uphp:functions:explode [2021/02/02 10:13]
admin
Line 47: Line 47:
  
 </code> </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)
 +  
 +</code> 
  
 ====See Also==== ====See Also====
uphp/functions/explode.txt · Last modified: 2021/09/13 05:57 (external edit)