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

  • Home
  • SEARCH
  • 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 8096345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:25:32+00:00 2026-06-05T21:25:32+00:00

i have a string 9 bedrooms in that house, but it could be anything

  • 0

i have a string “9 bedrooms in that house”, but it could be anything else, but bedroom keywords will stay (bed, beds, bedrooms, bedroom, etc.) <- this is $search_array variable

i have converted it into an array using explode

i need to find a word bedroom and to see if there is a number beside it.

assuming my array after explode is – (9, bedrooms, in, that, house), how can i check for a number beside it

i have used that code below and its inside a function hence $array =& $this->search_array

if($array =& $this->search_array){
$bedroom_keywords = array('bed', 'beds', 'bedroom', 'bedrooms');
foreach($this->bedroom_keywords as $beds)
        {   
            // if successful in assigning key find a 
            // number in next and previous positions
            if($key = array_search($beds, $array))
            {
                if($next = $array[$key+1])
                {
                    echo $next;
                }
                elseif($prev = $array[$key-1])
                {
                    echo $prev;
                }
            }
        }
}

but im getting this error:

Notice: Undefined offset: 2 in /Users/User/Sites/parser.php on line 92 9ad_type:

when i use just 2 tokens ie – “9 beds”.

is there any way i can check if there is a next/previous value in the array or do something so it’ll work?

thanks

  • 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-05T21:25:34+00:00Added an answer on June 5, 2026 at 9:25 pm

    You could use a regular expression for this task:

    ([0-9]+) +(bed|beds|bedroom|bedrooms)
    

    will find a number with at lease one digit, then any number of spaces, then one of those bed words.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string that look like Array that fetched from other webservice like this
I have string that displays UTF-8 encoded characters, and I want to convert it
i have string stored in python variables, and i am outputting a html that
I have string separated by dot ('.') characters that represents a hierarchy: string source
I have string: Lorem ipsum dolor [mytag]something[/mytag]sit amet, ipsum [mytag]something else[/mytag]a laoreet ultricies and
i have string (uri) that i need to decode in c++ , its have
I have string that I want to chop to array of substrings of given
I have string with product information and I would like to parse that string
I have string that contains html . The html has several img tags in
i have string that contains apostrophe and comma's and when i execute insert into

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.