PHP delete everything after comma (including comma)

admin

Administrator
Staff member
I just can't get my head around the syntax for this. I have an array
Code:
$foo
and I call it within a function:
Code:
wp_list_pages($foo);
(this is a wordpress site).

I found this code online but can't get it to work...
I've tried both of these ways and it doesn't seem to do anything. Can anyone help?

Code:
 <?php $mystring = $foo;
list ($before,$after) = split (',', $mystring);
echo $before; 
?>
<?php wp_list_pages( $foo ); ?>

or this:

Code:
<?php $has_comma = (stristr($foo, ",")>-1) ? 1 : 0;
if ($has_comma) {
list ($before,$after) = split (',', $foo);
$foo = $before;
} ?>

<?php wp_list_pages( $foo ); ?>