Richard Coffre
asked on
String manipulation (reverse and delete)
Hi,
I want to transform string.
For example when I have this : "VOITURE (LA)" I want to obtain "LA-VOITURE".
So the steps are :
1. set the article at the beginning
2. delete the parenthesis
3. replace the space by a hyphen.
TIA
I want to transform string.
For example when I have this : "VOITURE (LA)" I want to obtain "LA-VOITURE".
So the steps are :
1. set the article at the beginning
2. delete the parenthesis
3. replace the space by a hyphen.
TIA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$first= 0;
$last = 0;
for ($i = 0; $i < strlen($str); $i++) {
if($str[$i] == '(' ) {
$first = $i ;
if ($str[$i] == ')') {
$last = $i ;
}
}
$i=0;
for ($j=$first+1 ; $j < $last; $j++) {
$rep[$i++] = $str[$j];
}
$rep[$i+1] = '"-"';
for ($k=0; $k < $first ; $k++){
$rep[$i++] = $str[$k];
}