Jump to content

[SOLVED] Array help...


Aureole

Recommended Posts

Thanks for your suggests laffin and kenrbrsn but I already know how to do it both of those ways.

 

$input = array
(
'home' => array( 'Home', 'something', 'something', 'index.php'),
'contact' => array( 'Contact', 'something', 'something',  'contact.php')
);
if( in_array( $_GET['file'], $input ) )
{
$input[$_GET['file']]
}

 

If the $_GET['page'] is home, I want to include index.php and I want to be able to access those other parts of the array ( array( 'Home', 'something', 'something', 'index.php') ), if it's contact then the same...

 

I know there are simple workarounds to tricky ideas, but it'd be nice to know how to do this anyway..

Link to comment
https://forums.phpfreaks.com/topic/90114-solved-array-help/#findComment-462494
Share on other sites

I worked it out, it was simpler than I thought.

 

<?php
$page = ( isset( $_GET['page'] ) && ( $_GET['page'] ) ) ? $_GET['page'] : 'home';

$input = array
(
'home' => array( 'Home', 'website', 'public', 'index'),
        'forum' => array( 'Forum Index, 'forum', 'forum', 'index'),
'contact' => array( 'Contact', 'website', 'public', 'contact')
);

if( array_key_exists( $act, $input ) )
{
require_once( ROOT_PATH . 'sources/' . $input[$act][2] . '/' . $input[$act][3] . '.' . $equinox->vars['php_ext'] );

$page_title = $input[$act][0];
$nav_current = $input[$act][1];

include( ROOT_PATH . 'sources/inc/header.' . $equinox->vars['php_ext'] );
echo( $page_html );
include( ROOT_PATH . 'sources/inc/footer.' . $equinox->vars['php_ext'] );
}
?>

Link to comment
https://forums.phpfreaks.com/topic/90114-solved-array-help/#findComment-462503
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.