Jump to content

Brandon_R

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

Everything posted by Brandon_R

  1. $result = preg_replace('#[0-9]#', '', $text);
  2. If im not mistaken, you want to convert relative to absolute urls? $newurl = str_replace('href="/', $url ,$var[0]);
  3. You will have to insert the unicode representative for that character in the character class if (preg_match('#[A-Z\x{00FF}]#iu', $text)) { echo 'Match Found'; } else { echo 'Match No Found'; }
  4. There is definitely a future for PHP. I see many new OOP features added onto it as the current is quite young.
  5. How do I find a '<!--' that is missing a '-->'? if (!preg_match('#(?><!--.*?(?=<!--|-->|$))(?!-->)#si', $html)) { echo 'Your HTML tag is valid because it contains both opening and closing comment tags'; } else { echo 'Your HTML tag is invalid because it doesn't contain a closing tag --> for the opening <!-- comment tag'; }
  6. Having a block with just keywords related to the webpage is called keyword stuffing and can get you blacklisted from the SERPs. Having about 5-10 tags describing the page is perfectly fine.
  7. You need to either pass along the $session variable as an argument in the function or globalize it. Passing it on as an argument function uploadtesting($session) { $user = $session->username; } Globalizing it function uploadtesting() { global $session; $user = $session->username; } For the variablie to be globalized you have to set it before the function is called same goes for passing it on as an argument.
  8. Considering the last 32 characters of the string is the hash and you want to remove it use this: $string = substr($string, 0, -32); If you want to remove everything except the hash use this $string = substr($string, -32); Again both is dependent on the 32 digit long hash being on the end of the string as you stated.
  9. Set your PHP code equal to the variable $code and when done $extractedcode will contain error_reporting(E_ALL ^ E_NOTICE); and everything after it. if (preg_match('#(error_reporting\(E_ALL \^ E_NOTICE\);.++)#si', $code, $extracted)) { $extractedcode = $extracted[0]; }
  10. Hello StarvingArtist welcome to PHP Freaks, I hope you enjoy the wealth of knowledge on this website and choose to become an active part of our community which judging from your post you already have. Once again welcome to the community.
  11. You cannot use the header function if output has already started or sent. If you visit page2.php directly it will redirect to example.com however embedding it in an HTML page will not work. You may want to try <meta http-equiv="refresh" content="0;url=http://example.com/">
  12. Using the function you specified <?php $input = $_POST['input']; $array = array(); if ($input == 'add_element') { $add_element = 'add_element_val'; $array = array_push($array, $add_element); } ?> Or you could simply add onto the end of the array like so <?php $input = $_POST['input']; $array = array(); if ($input == 'add_element') { $add_element = 'add_element_val'; $array[] = $add_element; } ?>
  13. This forum is made from SMF - Simple Machines Forum but may i suggest vBulletin. Its way better.
  14. Should be $secret_password = md5($password); And not $secret_password = md5("password");
  15. The function mysql_create_db will not be available if the mysql extension was built against a MySQL 4.x client library. This function is also depreciated. Use a mysql_query to create a DB instead.
  16. Hello guys, im now getting to know OOP and would like to know which is more efficient and faster. Normal OOP ($class->function) or Paamayim Nekudotayim (CLASS::function) Thanks.
  17. <?php include "db.php"; $grade = $_POST['grade']; $reg = $_POST['Names']; foreach ($grade AS $index => $pemhc) { $query = "INSERT INTO result (regNo, grade) VALUES ('$reg[$index]', '$pemhc')"; $result = mysql_query($query); } ?> PS PEMHC = pre school middle school high school & college for grade levels
  18. function first_sentence($content) { $pos = strpos($content, '.'); return substr($content, 0, $pos+1); } Source: http://www.electrictoolbox.com/get-first-sentence-php/
  19. Thanks for your help guys but i got it. Instead of doing the entire thing via ajax i just did the call to a php file that got the title and description and returned it.
  20. OK How to i get the site description only and not all meta tags
  21. Hello PHP Gurus and members alike i need some help with a piece of code. I would like to use php to get a website title and meta description from an inputted url. Thank You Brandon_R
  22. Hello wonderful users of this forum. I tried searching for this but to no avail. Can someone show me how to get the page title of a url and its meta description and return them onto the page in a textarea? I will be truly grateful. The only thing i can get right it the HTML aspect of this piece of code
  23. Actually king phillip can you show me how to check each array to make sure they contain the same number of values and if they don't echo out an error message such as this is not an array.
  24. How about simply halt execution. Ill add my error message later on when im finalizing the script.
×
×
  • 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.