0

im writing a wordpress plugin where i've encountered a problem.... how can i call my array $start from a function named inputFraInputtable into a function named time_registrering? below is the function i'm trying to call it to and where im calling it from

function time_registrering(){



inputtable_func();
inputFraInputtable(
$date,
$start,
$slut,
$pause,
$egenb,
$tot
);
print_r($start);
echo $start[startA];
}


function time_registrering(){

 function inputFraInputtable() {
if(isset($_POST['submit'])) {
    global $_POST;
$date = array(
    'dateA'=>$_POST['dateA'],
    'dateB'=>$_POST['dateB'],
    'dateC'=>$_POST['dateC'],
    'dateD'=>$_POST['dateD'],
    'dateE'=>$_POST['dateE'],
    'dateF'=>$_POST['dateF'],
    'dateG'=>$_POST['dateG'],
);
    $start = array(
    'startA'=>$_POST['startA'], 
    'startB'=>$_POST['startB'], 
    'startC'=>$_POST['startC'], 
    'startD'=>$_POST['startD'], 
    'startE'=>$_POST['startE'], 
    'startF'=>$_POST['startF'],
    'startG'=>$_POST['startG'],
    );
$slut = array(
    'slutA'=>$_POST['slutA'],
    'slutB'=>$_POST['slutB'],
    'slutC'=>$_POST['slutC'],
    'slutD'=>$_POST['slutD'],
    'slutE'=>$_POST['slutE'],
    'slutF'=>$_POST['slutF'],
    'slutG'=>$_POST['slutG'],
    );
$pause = array(
    'pauseA'=>$_POST['pauseA'],
    'pauseB'=>$_POST['pauseB'],
    'pauseC'=>$_POST['pauseC'],
    'pauseD'=>$_POST['pauseD'],
    'pauseE'=>$_POST['pauseE'],
    'pauseF'=>$_POST['pauseF'],
    'pauseG'=>$_POST['pauseG'],
);
$egenb = array(
    'egenbA'=>$_POST['egenbA'],
    'egenbB'=>$_POST['egenbB'],
    'egenbC'=>$_POST['egenbC'],
    'egenbD'=>$_POST['egenbD'],
    'egenbE'=>$_POST['egenbE'],
    'egenbF'=>$_POST['egenbF'],
    'egenbG'=>$_POST['egenbG'],
);
$tot = array(
    'totA'=>$_POST['totA'],
    'totB'=>$_POST['totB'],
    'totC'=>$_POST['totC'],
    'totD'=>$_POST['totD'],
    'totE'=>$_POST['totE'],
    'totF'=>$_POST['totF'],
    'totG'=>$_POST['totG'],
);
}
}
0

1 Answer 1

0

E.g. by passing that array as an parameter of the function

<?php
foo();

function foo() {
    $start = array('x','y','z');

    echo '[', bar($start), ']';
}

function bar(array $items) {
    return join(', ', $items);
}

foo() somehow builds an array, passes it to bar(), bar() does something with it and returns something. That return value again is echo's in foo().

see:
http://docs.php.net/language.variables.scope
http://en.wikipedia.org/wiki/Dependency_injection

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.