in the string XX is always changed and string can be longer or shorter and it can be without searched word, where XX is a number
example:
1 kom. nije naručeno, obično dolazi za 5 dana., slični: sony-6am6ptb1a (0 kom.), sony-s006pb1a (-9 kom.)
So from that I need to output just: obično dolazi za 5 dana
So how can I chose just &find in any case?
$find = "obično dolazi za XX dana.";
$string ="1 kom. nije naručeno, obično dolazi za XX dana.";
if (strpos($string,$find) !== false) {
echo '$string contains $find';
}
I think this is it:
$string = "1 kom. nije naručeno, obično dolazi za XX dana.";
for(int intIndex = 1; intIndex <= 31; intIndex++)
{
$find = "obično dolazi za " . strval(intIndex) . " dana."
if (strpos($string,$find))
{
echo '$string contains $find';
}
}
I am assuming that the ‘search string’ has a portion (
XX) that changes and you don’t necessarily know what it will be in a given situation. So you can’t usestrposbecause of the unknown segment.You’ll have to use a regular expression based on the left and right parts of the search string.
Please see PHP Manual: preg_match for more details.
Without knowing what `XX’ represents I can’t offer anything more.
Or…
If you want to return the
XXand the left-most and right-most parts are constant…Output is
XX.Or…
Is this good enough for your needs..? [It is based on what you came up with! 🙂]