Hi,
How can I make sure that the entered list is comma separated correctly? It must be a,b,c,... and not a,,b,c,-,d with other wrong separators or some thing similar.
the right format for me is String1,String2,String3,...
Thanks in Advance.
Make sure the list is comma seperated
Moderator: General Moderators
- silvercover
- Forum Newbie
- Posts: 10
- Joined: Thu Sep 20, 2007 10:17 am
Re: Make sure the list is comma seperated
What about that?
But I am not sure if i get your point. This solution is very easy and stupid.
Code: Select all
function checkList($list){
$x = explode(",",$list);
foreach($x as $y){
if(empty($y) ||
preg_match('/[-_;]/',$y)) // Put all needed separators into regular expression.
return false;
}
return true
}