Jump to content

[SOLVED] Quick string question


The Bat

Recommended Posts

Here is a function that you could use, it is a little more robust.  Covers several cases:

 

<?php
function foo($string) 
{
$parts = explode('_', $string);

if (count($parts) > 0) 
{
	$end = end($parts);

	if (($pos = strrpos($end, '.')) !== false) 
	{
		return substr($end, 0, $pos);
	} 
	else 
	{
		return $end;
	}
}
return $string;
}
?>

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.