I have the code below and it's returning undefined on the countingNumbers variable. I need to implement the class name numbered so I can loop over in JavaScript and give them separate "Read More" tags.
<?php $countingNumbers = 0 ?>
            <?php 
            
            function custom_echo($x, $length){
                if(strlen($x)<=$length)
                    {
                        echo $x;
                    }
                    else
                    {   
                        $y=substr($x,0,$length) . '...';
                        echo $y;
                        echo '<div class="service-about__link' . $countingNumbers . '">
                                READ MORE
                              </div>';
                    }
                } 
            ?>
            @foreach($services as $service)
            <?php $countingNumbers++ ?>
            
            <div class="service-about movement{{$countingNumbers}} row row-margin">
                <div class="col-lg-6">
                    <h3 class="service-about__title">
                        {!!$service->title!!}
                    </h3>
                    
                    <div class="service-about__content-small">
                        <?php 
                        custom_echo($service->content, 200); ?>
                    </div>
                    <div class="service-about__content-large">
                        {!!$service->content!!}
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="service-about__image">
                        <img src="{{url('')}}/img/services/{{$service->image}}">
                    </div>
                </div>
            @endforeach
 
    