Using the string functions

Functions that covert strings to arrays

explode($sep, $str)
implode($sep, $sa)

How to convert a string to an array

<?php
  $names = 'Mike|Anne|Joel|Ray';
  $names = explode('|', $names);
  $name1 = $names[0];    // $name1 is 'Mike'
  $name2 = $names[1];    // $name2 is 'Anne'
?>

How to convert an array to a string

$names = implode('|', $names); // $names is 'Mike|Anne|Joel|Ray' ?>

How to convert an array to a tab-delimited string

<?php  
  $names = implode("\t", $names);
?>

Back