hi,

suppose there's a string
$string="I like my(hot) coffee with sugar and (milk)(PHP)";

I would like to get an output of all possible combinations of the sentence 
with the words between brackets:
eg. 
I like my hot coffee with sugar and
I like my hot coffee with sugar and milk
I like my hot coffee with sugar and milk php
I like my coffee with sugar and
I like my coffee with sugar and milk php
etc.etc.

The number of the words between brackets can differ and they can occur 
everywhere. The most important is that all combinations are returned but the 
sentence (not between brackets) should be there.

I got something like:
preg_match("/\((.*?)\)(.*)\((.*?)\)+/",$string,$regresult);


but the \((.*?)\) part that matches the things between brackets is fixed. 
There can be a variable number of these words between brackets. How do i do 
this? And how could i easily get the combinations? Can i do it all just with 
preg_match or should i construct the combinations with some additional code?

thanks;
Simon



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to