pengume Posted July 4, 2010 Share Posted July 4, 2010 Hello, I am new to php and want to know if this code I am using is correct. I am trying to use preg_match() to check if there is a certain word in a variable. If the word is found then I want to display a different image then if it is not found . the code I am using isn't working right now. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; $check_img = preg_match('(pheedo|feedburner)',$first_img); if ($check_img == false) { $new_img_tag = "<img src='http://www.searchforhealth.com/wp-content/uploads/2010/06/featured-default.gif' width='67px' class='alignleft' />"; } else { $new_img_tag = "<img src='" . $first_img . "' width='300px' class='alignleft' />"; } Quote Link to comment Share on other sites More sharing options...
salathe Posted July 5, 2010 Share Posted July 5, 2010 How is it "not working"? Can you give us an example string which misbehaves? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.