Hi all,
im trying to use preg_match with my search function at the moment without using preg_match it matches the search term if its entered exactly as it is in my feed but even if its spelt the same but the caps are not in the correct place it wont find anything
so i need to use preg_match so that it pulls out all instances of the search value whether its entered in caps or not and if there is string around the text other than the text i want.
hope this makes sence?
here is my attempt but nothing is showing
this below works if its matched EXACTLY
any ideas on how i can get this working?
cheers all
im trying to use preg_match with my search function at the moment without using preg_match it matches the search term if its entered exactly as it is in my feed but even if its spelt the same but the caps are not in the correct place it wont find anything
so i need to use preg_match so that it pulls out all instances of the search value whether its entered in caps or not and if there is string around the text other than the text i want.
hope this makes sence?
here is my attempt but nothing is showing
PHP Code:
if (isset($_POST['Search'])){
$test = $_POST['Search'];
}
$feedurl = "http://www.kernow-connect.com/feeds/play.xml";
$xml=simplexml_load_file($feedurl);
foreach ($xml->merchant->prod as $item){
if (preg_match("/\$test\b/i",$item->text->name)){
list($width, $height) = getimagesize($item->uri->mImage);
echo"
<div class='inditemheader'>
<a href='{$item->uri->awTrack}'>{$item->text->name}</a></div><br />
<div class='inditemimg'>
<a href='{$item->uri->awTrack}'>
<img src='{$item->uri->mImage}'
alt='{$item->text->name}' "
.($width>$height?"width='120'":"height='100' ").
"border='0'
vspace='0' /></a>
</div>
<div class='inditemprice'>
Buy Now For £{$item->price->buynow}
</div>";
}
}
PHP Code:
if (isset($_POST['Search'])){
$test = $_POST['Search'];
}
$feedurl = "http://www.kernow-connect.com/feeds/play.xml";
$xml=simplexml_load_file($feedurl);
foreach ($xml->merchant->prod as $item){
if ($item->text->name == $test){
list($width, $height) = getimagesize($item->uri->mImage);
echo"
<div class='inditemheader'>
<a href='{$item->uri->awTrack}'>{$item->text->name}</a></div><br />
<div class='inditemimg'>
<a href='{$item->uri->awTrack}'>
<img src='{$item->uri->mImage}'
alt='{$item->text->name}' "
.($width>$height?"width='120'":"height='100' ").
"border='0'
vspace='0' /></a>
</div>
<div class='inditemprice'>
Buy Now For £{$item->price->buynow}
</div>";
}
}
cheers all
Comment