Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Not sure, but I think you meant something like this: $string = "1,3,5,6,8,9"; if(in_array($number, explode(',', $string))) { // ... }
  2. Doh, I should have realized, I remember someone else encountering a similar problem like this a while back. The solution? From the manual on variable variables. http://php.net/manual/en/language.variables.variable.php
  3. By the way, when a topic is solved we appreciate it if you mark it as such. There's a button at the bottom of the page to do so.
  4. To open and close the echo you're using double quotes, so if you want to use double quotes anywhere inside of the string you must escape them, so it doesn't think you want to stop the echo there.
  5. You have to escape the quotes. echo "<table bgcolor=\"#DBEDE9\" align=center width=\"600\" style=\"border:5px outset green\">";
  6. Disabling directory browsing is always a good idea.
  7. So... $field_value = ${"_" . $this->Method}[$field_name]; echo $field_value; // Nothing? echo $_POST[$field_name]; // This works though?
  8. Does $this->Method contain 'POST'? Because that should work. $_POST['var'] = 'val'; $method = 'POST'; $key = 'var'; echo $var = ${'_' . $method}[$key];
  9. Is the id supposed to be coming from $_POST? If so then you should be using $p['id'] instead of $id in the function.
  10. You can check to see if you already have it installed by using: echo phpinfo(); If you don't have it installed, and you're on shared hosting you won't be able to install it. In that case you can use an API like this one.
  11. $movies = Array( 0 => Array( 'id' => 1, 'year' => 1984, 'title' => 'The Terminator' ), 1 => Array( 'id' => 2, 'year' => 1994, 'title' => 'True Lies' ) ); $movies = array_map( create_function( '$movie', 'if(strtolower(substr($movie["title"], 0, 3)) == "the") { $movie["title"] = substr($movie["title"], 4) . ", " . substr($movie["title"], 0, 3); } return $movie;' ), $movies ); print_r($movies); Output: Array ( [0] => Array ( [id] => 1 [year] => 1984 [title] => Terminator, The ) [1] => Array ( [id] => 2 [year] => 1994 [title] => True Lies ) )
  12. You can do this easily using the geoip extension if you have it installed.
  13. I'm not sure variable variables are the way to go in this case, but the code you're looking for is: $field_value = ${'_' . $this->Method}[$field_name];
  14. $id is undefined in that context.
  15. You mean something like this? $x = sizeof($arr); while($x > 0) { --$x; echo $arr[$x]; }
  16. Huh? I'm not sure what you're asking. Can you explain it better or give us an example?
  17. The leading spaces won't have an effect when the string is converted to an integer for the arithmetic. You're just missing a $. echo $explode10[0]+$explode11[0];
  18. Is that function a method of modernCMS object?
  19. How did you try array_reverse? Something like this should work: foreach (array_reverse($xml->result->rowset->children()) as $gen)
  20. That should work, if it's not working for you it's likely another problem and you need to provide us with relevant code to help us help you.
  21. You could use output buffering, but problems like this are typical and in most cases it's not necessary to use output buffering.
  22. Like cags said: $query = "SELECT t1.friend, t1.relation, t1.community, t2.street, t2.people FROM table1 t1 JOIN table2 t2 ON t1.email=t2.email WHERE username = '$username'";
  23. register_globals does this, but it's depreciated and a huge security risk, so I do not suggest you use this. As for the code you're after, I think you want something like this: foreach($_GET as $var => $val) { $$var = $val; } But again, this poses the same security flaw as register_globals, because anyone can inject their own variables into your script, so again I do not suggest you use this.
  24. Go to your profile and then click "Show Posts", or use this link: http://www.phpfreaks.com/forums/index.php?action=profile;area=showposts;u=65099
  25. If you're inside of double quotes you can use echo array values like that as long as you don't use single quotes around the keys.
×
×
  • 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.