php strings

Associate
Joined
12 Jun 2003
Posts
898
Location
Wicklow, Ireland
hey guys bit of a pickle here.

i have example text that i get from a text box from a user and looking at the best way to split them up using the least amount of code possible.

i have a php class that stores

number of rooms [1,2....10]
type [rent/let or sale]
area [the area it's in]
price [the price]


here are some example searches.

* 5 bed rent
* Camden 3 bedroom for sale
* 2 bed apartment to let London
* 3 or 4 bed house to rent in Notting Hill for 1000 per month

what's the best way to extract the data using php with out me knowing what way the user will enter the data.

this is for a progamming test so it doesn't have to be 100% functional.

thanks.
 
well it's for a test for a job.

basically they specify that the key data that i want could be in any format and just give them four examples.

they say that things like number of bedrooms will always be an int and not string ie. 4 instead of "four" same for the money values.

just really hit a brick wall on where to start.

like i've done regexes in perl before but i find them harder in php especially extracting the matches into variables it's different in php
 
Last edited:
ok i've got this working, but i've snagged another problem.

i get the results i want for a SOAP request.

PHP:
$response = $API->search_rental($parameters);
$results = $response->results;
      					
print "$results->search_sentence <br />";
			
			
foreach($results->ads as $ad)
{
	if($ad->area == $this->get_area())
	{
		printf('<a href="%s">%s</a><br />', $ad->url, $ad->full_address);
    	}
    	else
    	{
    		printf('<a href="%s">%s</a><br />', $ad->url, $ad->full_address);
    	}
 }

what i want to do is if $this->get_area() returns a value i want to only print out that ads that contain the same value in $this->get_area() as in $ad->area, but if $this->get_area() doesn't hold a value i want to print out all the ads.

the code above will print out all the ads regardless.

anyone any pointers?
 
Back
Top Bottom