Append and Prepend a string
Login or Register to Bookmark this snippet
This function ties the $pre to the start of $string, if $pre is not already there. Also does the same to the end of the string with $post.
<?php
function TieString($string,$pre='',$post='') {
//tie the pre - check if not already tied.
if (strpos($string,
$pre) !==
0) {
$string = $pre . $string;
}
}
//tie the post - check if not already tied
//get sub
if ($t != $post) {
$string .= $post;
}
}
return $string;
}
?>
Added by JC on 11th November, 2007
There are no comments about this snippet.
You must be registered and logged in to post a comment.
Login here to post a comment