waplet Posted February 13, 2010 Report Share Posted February 13, 2010 Atsaucoties uz bubu veido, $a = array("news", "topics", "whatever"); kā, lai uztaisa, ka , ja piemēram, if(in_array($_GET['p'])){.. lai inklūdo piemēram, jebkādu , kādu grib norādītu php failu.. kā tas būtu jātaisa, tas divdimensionālais arrays :? Link to comment Share on other sites More sharing options...
2easy Posted February 13, 2010 Report Share Posted February 13, 2010 (edited) šis inklūdos "jebkādu" lapu, bet tikai no arraya ;) $a = array("news", "topics", "whatever"); if (in_array($_GET['p'], $a)) include $_GET['p'] . '.php'; else include 'defaultais.php'; ohh, un to visu, protams, var vienā rindiņā ar ternary operatoru: include (in_array($_GET['p'], array("news", "topics", "whatever")) ? $_GET['p'] : 'defaultais') . '.php'; Edited February 13, 2010 by 2easy Link to comment Share on other sites More sharing options...
waplet Posted February 13, 2010 Author Report Share Posted February 13, 2010 bet bet bet... ja piemerām failiem ir citi nosaukumi.. kurus "nedrīkst" mainīt :? Link to comment Share on other sites More sharing options...
briedis Posted February 13, 2010 Report Share Posted February 13, 2010 Sa-map-o :) $mapping = array( "raksts" => "articles.php", "faili" => "files.php", "register" => "register.php" ); $file_path = $mapping[$_GET['id']]; include file_exists($file_path) ? $file_path : "default.php"; piemēram... Link to comment Share on other sites More sharing options...
waplet Posted February 13, 2010 Author Report Share Posted February 13, 2010 Jap tā biju domājis, bet nevarēju izdomāt.. paldies :) Link to comment Share on other sites More sharing options...
Recommended Posts