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?
in_array problem
Re: in_array problem
Yeah in_array effectively looks like this
[syntax=php]function in_array($test, $array){
foreach ($array as $value){
if ($value == $test){
return true;
}
}
return false;
}[/syntax]
you the way you are doing it will probably not work.
Why does the array even have to be 2D though :s ? Surely no pages will have the same name ?
[syntax=php]function in_array($test, $array){
foreach ($array as $value){
if ($value == $test){
return true;
}
}
return false;
}[/syntax]
you the way you are doing it will probably not work.
Why does the array even have to be 2D though :s ? Surely no pages will have the same name ?
Re: in_array problem
I'm using the fetch_array function from the MySQL class,
[syntax=php]
public function fetch_array(){
$results = array();
while ($this->fetch($row)){
$results[] = $row;
}
return $results;
}
[/syntax]
[syntax=php]
public function fetch_array(){
$results = array();
while ($this->fetch($row)){
$results[] = $row;
}
return $results;
}
[/syntax]
Re: in_array problem
I would try fetch and create the array manually
[syntax=php]while ($mysql->fetch($row)){
$static_pages[] = $row['page_name'];
}[/syntax]
something along those lines
[syntax=php]while ($mysql->fetch($row)){
$static_pages[] = $row['page_name'];
}[/syntax]
something along those lines