The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

PHP define function as array

  • # June 21, 2009 at 9:54 am

    You know you get arrays and you can define your own function, can and how do you merge them.

    So i define the function help() and use help(heart,blood,ab) to call it

    # June 21, 2009 at 10:18 am

    Not sure. You can pass an array to a php function and access it like any array.

    $arr = array(“one”, “two”, “three”);


    function help($args) {
    foreach ($args as $arg) {
    echo $arg . “n”;

    Or you can access the list of passed variables using fung_get_args().

    help2(“one”, “two”, “three”);

    function help2() {
    foreach( func_get_args() as $arg) {
    echo $arg . “n”;

    # June 21, 2009 at 10:44 am

    that first idea is good idea!!!! just what I wanted thanks. Matt

    # June 21, 2009 at 11:12 am

    Thanks, but I got confused lol.

    This is what I have so far

    < ?php if( $_SERVER['HTTP_HOST'] == '') { header( 'Location: ../1' ); } if( $_SERVER['HTTP_HOST'] == '') { header( 'Location: ../2' ); } ?>

    I want to set it up so I don’t need these wasted instructions. Something like this because I will have alot of domains.

    < ?php //Define function here redirect('','../1'); redirect('','../2'); ?>

    BTW i know I cannot use redirect, but i’m not very creative atm. :D

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed