Jump to content

chrsm

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

chrsm's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I would recommend reading the PHP manual, on the "type comparison" page: http://www.php.net/manual/en/types.comparisons.php $a 'exists' but is set to NULL; isset and is_null will return FALSE and TRUE, respectively. NULL is not really a value, but the variable exists. For example: $ php -r 'if(is_null($b)) { echo("\$b is null\n"); }' PHP Notice: Undefined variable: b in Command line code on line 1 Notice: Undefined variable: b in Command line code on line 1 $b is null $b, in this case, was undefined, and something that isn't set is "NULL" in a way, but since it isn't set, it's going to trigger an error. If $b had be assigned NULL in a previous expression, there would be no warning triggered. Furthermore, there is no default value for a variable, so one cannot define a variable like so: $b; Without assigning it to anything. It will trigger an error if $b is referenced by an expression. $ php -r '$b; echo($b);' PHP Notice: Undefined variable: b in Command line code on line 1 Notice: Undefined variable: b in Command line code on line 1 Anyways, the tables on the page I linked have a very good explanation of how these things all map to each other. Cheers.
  2. Can i use a While cicle to generate the 15 random numbers? And to convert the numbers into roman use a "SWITCH CASE" for each number? Yes. I won't provide the whole set of code, but here's some psuedocode for you: results = array(); i = 1; while(i <= 15) { switch(i) { case 1: results[] = 'I'; break; case 2: ...etc } }
  3. Have an array map of 1-10 to their Roman numeral equivalents. Create an empty array to store the generated numbers in. Use a for loop to go from 1 to 15 (or 0 to 14 if you are so inclined), each time storing the result from the random lookup in the (previously) empty array you created. For example: $numerals = array(1 => 'I', 2 => 'II', 3 => 'III', ...etc); $results = array(); for($i = 1; $i <= 15; $i++) { $rand = rand(1,10); $results[] = $numerals[$rand]; } And then functionize it.
  4. In CI, you do not use the file extension unless the file is not a php file Ah, my bad. I was going with my memory, I haven't used CodeIgniter in a while =)
  5. If it's a view ("template"), you'll want to use the "load" object inside the controller, for example: public function someAction() { $this->load->view('menu.php'); } If it is a "helper" or some kind of library, make sure it is in the right directory according to http://codeigniter.com/user_guide/libraries/loader.html.
  6. He's also missing something: 0x7FFFFFFF, not FFFFFFFF. function random($x){ $x = ($x << 13) ^ $x; return ( 1.0 - ( ($x * ($x * $x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); } echo random(3);
×
×
  • 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.