Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9012211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:56:22+00:00 2026-06-16T02:56:22+00:00

in the string XX is always changed and string can be longer or shorter

  • 0

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';
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:56:23+00:00Added an answer on June 16, 2026 at 2:56 am

    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 use strpos because 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 XX and the left-most and right-most parts are constant…

    // given '1 kom. nije naručeno, obično dolazi za XX dana.'
    
    $string = str_replace("1 kom. nije naručeno, obično dolazi za ", "", str_replace(" dana.", "", $string));
    // $string now contains the value of 'XX'
    
    print $string;
    

    Output is XX.

    Or…

    Is this good enough for your needs..? [It is based on what you came up with! 🙂]

    <?php
        // just throwing '23' in there to demonstrate the awesome power!
        $string = "1 kom. nije naručeno, obično dolazi za 23 dana.";
        for ($intIndex = 1; $intIndex <= 31; $intIndex++) {
            $find = "1 kom. nije naručeno, obično dolazi za " . strval($intIndex) . " dana.";
    
            // we test that it's not 'false', because it could be '0'
            if (strpos($string, $find) !== false) {
                echo "$string contains $find";
            }
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm always struggling with something like the following Java example: String breads[] = {Brown,
I need to break apart a string that always looks like this: something --
the Text property of control on winform is always string type, so if i
I have print $str; abcd*%1234$sdfsd..#d The string would always have only one continuous stretch
string format is always like this FirstName=ABC;LastName=XZY;Username=User1;Password=1234. I need the only UserName value (which
I am always confused about return a string literal or a string from a
One should always use std::string over c-style strings( char * ) is advice that
I tried many things but I always get cannot convert string to membershipuser from
There has always been a confusion with preg_match in php. I have a string
I'm always confusing about this stuff. I have this query : string[] names =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.