I need to remove a single character from a string, eg in the text block below I would need to be able to remove ONE of the j's.
djriojnrwadoiaushd
leaving:
driojnrwadoiaushd
I need to remove a single character from a string, eg in the text block below I would need to be able to remove ONE of the j's.
djriojnrwadoiaushd
leaving:
driojnrwadoiaushd
You can also use str_relpace with the $count parameter: $str = 'djriojnrwadoiaushd'; echo str_replace('j', '', $str, 1);
Ups, sorry.. my bad.
Here is a real way:
$str = 'djriojnrwadoiaushd';
$pos = strpos( $str, 'j' );
if( $pos !== FALSE )
{
echo substr_replace( $str, '', $pos, 1 );
}