Jump to content

[SOLVED] IF Statement?


cahamilton

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.