in_array problem
Posted: Sun Jan 29, 2012 6:19 pm
Alright, so while working with a "client" he wanted the option to create static pages instead of being limited by dynamic pages; so I thought I would be good to implement static pages within my CMS so I did, I just have one problem right now with my init.inc file.
[syntax=php]
$main = new Main;
$static = $main->IsStatic();
$static_name = end(explode('/', $_SERVER['SCRIPT_NAME']));
if(in_array($static_name, $static ) {
header("Location: http://google.com");
}else {
$parser = new Parser;
$parser->ParseTemplate();
}[/syntax]
However this is not working. The static variable is an array filled with the names of the static pages (services.php, portfolio.php, clients.php)
This is how the static array looks,
[syntax=text]
Array
(
[0] => Array
(
[page_name] => services.php
)
[1] => Array
(
[page_name] => portfolio.php
)
[2] => Array
(
[page_name] => clients.php
)
)
[/syntax]
Is it not working because it's a multidimensional array?
[syntax=php]
$main = new Main;
$static = $main->IsStatic();
$static_name = end(explode('/', $_SERVER['SCRIPT_NAME']));
if(in_array($static_name, $static ) {
header("Location: http://google.com");
}else {
$parser = new Parser;
$parser->ParseTemplate();
}[/syntax]
However this is not working. The static variable is an array filled with the names of the static pages (services.php, portfolio.php, clients.php)
This is how the static array looks,
[syntax=text]
Array
(
[0] => Array
(
[page_name] => services.php
)
[1] => Array
(
[page_name] => portfolio.php
)
[2] => Array
(
[page_name] => clients.php
)
)
[/syntax]
Is it not working because it's a multidimensional array?