john80988
asked on
php split command
example of a string : Big Medium(20,2) Small(25,3)
1) want to redefined it to big medium small - so it need remove all (xxxxx) and convert to small letter
2) another is split it into array
expert pls help
1) want to redefined it to big medium small - so it need remove all (xxxxx) and convert to small letter
2) another is split it into array
expert pls help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here we go now tested:
<?php
$new=strtolower(preg_repla ce("/\(.*\ )/U","","B ig Medium(20,2) Small(25,3)"));
print($new);
$array=explode(" ",$new);
print_r($array);
?>
<?php
$new=strtolower(preg_repla
print($new);
$array=explode(" ",$new);
print_r($array);
?>
Open in new window
When this is done $newstring should contain the string without the ( ) and anything between them.
the following will split it at every space; you'll need to set that to an array
split(" ", $newstring);
However it says the above is deprecated.
http://php.net/manual/en/function.split.php
I highly suggest that you do a little reading when trying to do these. A good reference is found here:
http://www.php.net/manual/en/index.php