Jump to content

GeorgeMoney

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    GeorgeMoneyWP
  • MSN
    georgemoneywikipedia@gmail.com

Profile Information

  • Gender
    Not Telling

GeorgeMoney's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Is it possible to use a function in the regex itself? this doesnt work: [code] $datr = preg_replace("/\[SC\](.*)\[\/SC\]/i", '<a name="'.myurlen("$1").'"></a>', $datr);[/code]
  2. Is it possible to use a function in the regex itself? this doesnt work: [code] $datr = preg_replace("/\[SC\](.*)\[\/SC\]/i", '<a name="'.myurlen("$1").'"></a>', $datr);[/code]
  3. Or if you want them to press a 'confirm' button: [code]<?php if(isset($_POST['newip'])) {   if(isset($_POST['confirm'])) {     $newip = $_POST['newip'];     $oldtext = file_get_contents('config.php');     $newtext = preg_replace('/http:\/\/(.*)\//', "http://".$newip."/", $oldtext);     $fp = fopen("config.php", "w");     fwrite($fp, $newtext);     fclose($fp);   } else {     echo "Are you sure about that? <form method='post' action='$_SERVER[SCRIPT_URI]'><input type='hidden' name='newip' value='$_POST[newip]' /><input type='submit' name='confirm' value='confirm' /></form>";   } } else { ?> <form method="post" action="<?php echo $_SERVER['SCRIPT_URI'] ?>"> IP: <input type="text" name="newip" /><br> <input type="submit" value="submit" /> </form> <?php } ?>[/code]
  4. You could use this script (untested). [code] <?php if(isset($_POST['newip'])) { $newip = $_POST['newip']; $oldtext = file_get_contents('config.php'); $newtext = preg_replace('/http:\/\/(.*)\//', "http://".$newip."/", $oldtext); $fp = fopen("config.php", "w"); fwrite($fp, $newtext); fclose($fp); } else { ?> <form method="post" action="<?php echo $_SERVER['SCRIPT_URI'] ?>"> IP: <input type="text" name="newip" /><br> <input type="submit" value="submit" /> </form> <?php } ?>[/code]
  5. How would I go about deleting, copying, creating, and renaming directories themselves? I know all the functions to rename, delete, copy files but I cant seem to figure out to do it for directories. Any help would be appreciated! Thanks!
  6. Basically I have one index.php file. On the index.php file there is something like: [code]<?php require_once "includes.php"; starts(); editbutton(); if(isset($_GET['images'])) { require_once "images.php"; } elseif(isset($_GET['contact'])) { require_once "contactus.php"; } else { require_once "main.php"; } ?>[/code] The editbutton() checks if the user is logged in and adds an editbutton on top linking to a file editor if they are logged in. I also want to have the editbutton on main.php itself, so if the user wants to edit that they can easily. But if I do that, then I have the editbutton from main.php and the editbutton from index.php both on index.php. I want it to only use index.php's edit button on index.php and main.php's edit button on main.php. Is this possible?
  7. Would there be a way to have something be "not-included" when you include a file? The only way I can think of is having an if statement and if the $_SERVER['SCRIPT_....'] var doesn't match the ___FILE___ constant then don't execute the stuff you don't want included. Is this the only way?
  8. Is there a way to list all the files in a directory just using a php script, not any server-configuration? Or would I have to do something like a loop and go through the loop checking if random filenames exist? if so could someone help me to do that? Thanks in advance!
  9. I am making a random sentence generator thingy using my limited knowledge of php. I guess I have been confusing everyone. I think I have it working now, i just can't fix all the minor tiny bugs.
  10. Yes, thanks guys, you helped alot! The new problem is that I want to use a foreach to explode() the values in the main array, for example (I changed what I was supposed to do in the original post, because I found a different way then what I said earlier): [code]<?php $words = array( "people" => "me;you;us;joe", "foo" => "bar;foo;someone;yep" ); ?> [/code] So what I want to do is turn each key name into the name of the new array and the values seperated by a ";". For example, this doesn't work: [code]foreach ($words as $key => $value) { $key = explode(";", $value); }[/code] so I want for example a new array called $foo and another array called $people with the values as "me", "you", etc..... I'm pretty sure theres a way to do this but i'm not doing it right. Any help would be appreciated!
  11. Update: I just read a little more in the php manual and it says: [quote] As stated in the syntax section, there must be an expression between the square brackets ('[' and ']'). That means that you can write things like this: <?php echo $arr[somefunc($bar)]; ?> [/quote] . If so then why is it not working for me?
  12. When I try to call an array using a variable as the key's name it doesn't work. For example, $foo[$bar] doesn't work. Would there be any way to make this work? More specifically I want to make a random word thing. This code doesn't work, is there any way to make it work? [code] <?php $arr = array( 'foo', 'bar', 'foobar' ) $rand = $arr[rand(0, count($arr))]; echo "Hello, $rand"; ?>[/code] . And if I am able to get this to work, I would like to also make a way for a form to be able to get from the array, eg: [code] <?php $username = $_POST['username']; if(isset($arr[$username])) { echo "Welcome. Your name exists in our list!"; } else { ?> <form method="post"> <input name="username"> <input type="submit"> </form> <?php } ?> [/code] So can anyone help me with this? It has to be possible... I guess.....
  13. how do you make it so the first slash after the php file is equeal to a parameter? For example how would you make #1 equal to #2: 1: http://example.com/example.php?param=value 2: http://example.com/example.php/value so the / is equal to ?param= . Would this require changing a configuration file on the server?
  14. How do you make those "examples" like you see in many php things, like the comments are orange and strings are red and variables are blue and commands are green? Is there a predefined function to do this? or do you have to use a script? if so can someone show me? Sorry if this sounds a little stupid. Thanks in advance!
×
×
  • 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.