Jump to content

Mardoxx

Members
  • Posts

    193
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Mardoxx's Achievements

Member

Member (2/5)

0

Reputation

  1. Javascript+XML (aka ajax....) if you're wanting to keep it clean use php with get something like /table.php?id=1 then use cases case $id 1: echo table1.html 2: echo table2.html etc etc (I CBA with correct syntax)
  2. can you give the URL to where this is being called/run from? because $directory_no = count($page) - 2; comes out negative if it's run at server root
  3. http://www.mysite.com/index.php $_SERVER['PHP_SELF'] => /index.php $page = explode("/", $_SERVER['PHP_SELF']); $page[1] = index.php http://www.mysite.com/ $_SERVER['PHP_SELF'] => / $page = explode("/", $_SERVER['PHP_SELF']); $page = try removing your slashes
  4. What do you think extract() is for? extract(array('a' = > array('a' => 'not this'), 'b' => 'bus')) doesn't work //edit fix`d idk why i was evaling... <?php function newfn(array $data) { foreach($data as $key => $value) { $$key = $value; //works fine } // whatever here } ?>
  5. no, because then you have to remember what order you entered them in
  6. lol yeah then just a eval("$$key = $value;"); (just incase you had newfn(array('a'=>'apple', 'b'=>'array(\'44\'=>\'o hai\')')); or something ) hehe so simple! thanks
  7. I got the idea when helping here: http://www.phpfreaks.com/forums/index.php/topic,267209.0.html I've created this very sketchy function for pushing string variables into a function: (hopefully you can see how it works) <?php function arg_splitter($input,$arg_count=false,$args_num='args_num') { $split = preg_replace('/\$|\"/','', preg_split('/\"[\s,]+\$/',$input)); /* First this splits the inputted string on any number of commas * or spaces inbetween the characters " and $ * then it replaces all $ and " characters with nothing * my regex skillz suck. */ foreach ($split as $key=>$val) { $split[$key] = explode("=",$val); $assocarray[$split[$key][0]] = $split[$key][1]; //creates associative array so you can use extract on it } if($arg_count) { $assocarray[$args_num]=count($assocarray); } return $assocarray; } function newfn($inputs) { extract(arg_splitter($inputs,true,'arg_count')); // Only line needed to be added if(isset($override) && !is_null($override)) { echo "O MAYN, WE GOT OVERRIDDEN!!!!\n<br />"; echo "\$override = $override\n<br />"; return; } echo "\$a = $a\n<br />"; echo "\$b = $b\n<br />"; echo "\$c = $c\n<br />"; echo "\$d = $d\n<br />"; echo "\$arg_count = $arg_count\n<br /><br />"; } echo "Test 1: \n<br />"; newfn('$a="apple",$b="banana", $c="carrot",$d="date"'); echo "Test 2: \n<br />"; newfn('$override="apple, banana, carrot, duck"'); ?> gives an output of: Test 1: $a = apple $b = banana $c = carrot $d = date $arg_count = 4 Test 2: O MAYN, WE GOT OVERRIDDEN!!!! $override = apple, banana, carrot, duck Any easier/other way of doing this? thanks
  8. www.php.net/manual/ and it's free
  9. I'm SURE there's a built in function in PHP to manage DOM
  10. I had an idea: <?php function select($table,$a='', $b='',$c='') { if(func_num_args()==2){ $group = func_get_arg(1); echo "doing something with \$group: $group\n<br />\n"; } else { echo "doing something else with the other args:\n<br \>\n"; echo "\$a : $a, \$b : $b, \$c : $c"; } } echo "select(\"table\", \"group by 'row'\");\n<br />\n"; select("table", "group by 'row'"); echo "\n<br/><br/>"; echo "select(\"table\", \"apple\", \"boat\", \"cow\");\n<br/>\n"; select("table", "apple", "boat", "cow"); echo "\n<br/><br/>"; ?>
  11. how about <?php static function select($table,$group='',$column='',$where='',$limit='',$limitto='',$groupby='',$orderby=''){ if(!isnull($group)){ //process $group } else { //process rest of the stuff } } but for EVERY Database::select I think you'd have to do select(table,'',column, where,.....etc)
  12. AND SET idk if tha will work.. but SET name=thing, name2=thing2, etc etc etc
  13. http://en.wikipedia.org/wiki/Ternary_operation#PHP
×
×
  • 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.