Quick actions

cmd+k|ctrl+k

Navigation

Languages

Leaving JS URL to end with Array() in PHP

Snippet info

Language

Php

Visibility

public

Author

mertskaplan

Created

2016-12-28T13:38:35Z

Updated

2016-12-29T15:19:30Z

<?php
$root = 'https://domain.com/';
$scriptURLs = array();

/* add script url */
$scriptURL = <<<JS
<script src="bootstrap/js/bootstrap.min.js"></script>
JS;
array_push($scriptURLs, $scriptURL);

/* add script url */
$scriptURL = '<script src="'. $root .'bootstrap/js/bootstrap.min.js"></script>';
array_push($scriptURLs, $scriptURL);

/* function */
function scriptURLs($tab = 0) {
    $t = '';
	if ($tab != 0) {
		do {
			$t .= "\t";
			$tab--;
		} while ($tab > 0);
	}
    global $scriptURLs;
    if (isset($scriptURLs[0])) {
        foreach ($scriptURLs as $scriptURL) {
            echo "\n".$t.$scriptURL;
        }
        echo "\n";
    }
}
/* using */
scriptURLs(); // or
scriptURLs(1); // with tab
INFO