cahamilton Posted April 19, 2009 Share Posted April 19, 2009 Hey guys. Im having abit of trouble with my IF statements at the minute. The scenario is, I have two strings: bio_scrape_large and bio_scrape_small. Basically, what I want to happen is, if the small and large bio's are the same character length, then I don't want the page to echo out anything. But if the large bio is bigger than the small one in character length, I'd like it to echo out the Read More and Read Less div's you see in the code. I've tried doing multiple IF's statements in there, that doesnt seem to work. It doesn't seem to like it when I do else or elseif either. I think I may have it structured incorrectly. Can someone point me in the right direction lol <?php if (str_word_count($bio_scrape_large) > str_word_count($bio_scrape_small)); {echo " <div id='bio_small' style='display: block'> $bio_scrape_small<a href=\"javascript:void(0)\" onclick=\"Show('bio_large'); Hide('bio_small')\" class='readmore'>Read More</a> </div> <div id='bio_large' style='display: none'> $bio_scrape_large<a href=\"javascript:void(0)\" onclick=\"Hide('bio_large'); Show('bio_small')\" class='readless'>Read Less</a> </div> "; } elseif (str_word_count($bio_scrape_large) == str_word_count($bio_scrape_small)); {echo "";} endif; ?> Link to comment https://forums.phpfreaks.com/topic/154780-solved-if-statement/ Share on other sites More sharing options...
bloodgoat Posted April 19, 2009 Share Posted April 19, 2009 Umm... did you try this? <?php if(str_word_count($bio_scrape_large) > str_word_count($bio_scrape_small)){ echo "<div id='bio_small' style='display: block'> $bio_scrape_small<a href=\"javascript:void(0)\" onclick=\"Show('bio_large'); Hide('bio_small')\" class='readmore'>Read More</a> </div> <div id='bio_large' style='display: none'> $bio_scrape_large<a href=\"javascript:void(0)\" onclick=\"Hide('bio_large'); Show('bio_small')\" class='readless'>Read Less</a> </div>"; } elseif(str_word_count($bio_scrape_large) == str_word_count($bio_scrape_small)){ echo ""; } ?> Link to comment https://forums.phpfreaks.com/topic/154780-solved-if-statement/#findComment-813941 Share on other sites More sharing options...
cahamilton Posted April 19, 2009 Author Share Posted April 19, 2009 Just fixed the problem and found out I was throwing in a few characters that weren't needed. Cheers for your help though bloodgoat, much appreciated! Link to comment https://forums.phpfreaks.com/topic/154780-solved-if-statement/#findComment-813953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.