Trying to find 1 hr without any luck.

I wish to get value during my template for radio button group. I've attempted below code although not working. Help me.

                    <?php if ( get_post_meta($post->ID, 'withincontent') == 'halfcontent') { ?>

                        <!-- after half content -->
                        <?php
                            $content = apply_filters('the_content', $post->post_content);
                            $content = explode(' ', $content);
                            $halfway_mark = ceil(count($content) / 2);
                            $first_half_content = implode(' ', array_slice($content, 0, $halfway_mark));
                            $second_half_content = implode(' ', array_slice($content, $halfway_mark));
                            echo $first_half_content.'...';
                            echo '<h2>Your adsense code</h2>';
                            echo $second_half_content;
                        ?>
                        <!-- end of after half content -->

                    <?php } elseif if ( get_post_meta($post->ID, 'withincontent') == 'paragraph') { ?>

                        <!-- after defined paragraph -->
                        <?php
                        $paragraphAfter= 1; //display after the first paragraph
                        $content = apply_filters('the_content', get_the_content());
                        $content = explode("</p>", $content);
                        for ($i = 0; $i <count($content); $i++ ) {
                        if ($i == $paragraphAfter) { ?>
                        <div>Insert Ads Here</div>
                        <?php }
                        echo $content[$i] . "</p>";
                        } ?>
                        <!-- end of after defined paragraph --> 

                    <?php } ?>