Jump to content

Parse String


verdrm

Recommended Posts

You can use preg_split to split a string by multiple delimiters. Example:

 

<?php
$str = "john + 10/20/2008 - 10/30/2008";
$var = array_map('trim', preg_split('~\+|\-~', $str));
echo $var[0]; // john
echo $var[1]; // 10/20/2008
echo $var[2]; // 10/30/2008
?>

Link to comment
https://forums.phpfreaks.com/topic/186301-parse-string/#findComment-983870
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.