is PHP the correct way ?

Technical Support
  • I am attempting to learn and setup nodebb. I had started developing on SMF and php. I am wanting to know the best way to encorporate this code. It is being used to get/supply images for a random image div that fades in and out

    $imagesDir = 'images/eggs/';
    
    $eggs = array();
        foreach (glob("images/eggs/*.{jpg,png,gif}", GLOB_BRACE) as $filename) {
            $eggs[] = $filename;
    }
        echo "<script>var eggs =" . json_encode($eggs) . "</script>";
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    function runIt() {
    		var nest1 = $('#nest1');
    		nest1.animate({opacity:'0'}, 4500);
    		nest1.animate({opacity:'1'}, 4500, runIt);
    		var nest2 = $('#nest2');
    		nest2.animate({opacity:'0'}, 4500).delay(800);
    		nest2.animate({opacity:'1'}, 4500, runIt);
    		var nest3 = $('#nest3');
    		nest3.animate({opacity:'0'}, 4500).delay(600);
    		nest3.animate({opacity:'1'}, 4500, runIt);
    		var nest4 = $('#nest4');
    		nest4.animate({opacity:'0'}, 4500).delay(400);
    		nest4.animate({opacity:'1'}, 4500, runIt);
    		var nest5 = $('#nest5');
    		nest5.animate({opacity:'0'}, 4500).delay(500);
    		nest5.animate({opacity:'1'}, 4500, runIt);	
    	}
    	runIt();
    
  • @flexxall said in is PHP the correct way ?:

    You can still use PHP by installing in on your webserver (nginx/apache), that may be the best option if you have a large amount of PHP code already.


Suggested Topics


| | | |