Help with text grabing.

Page Title Module
Move Remove Collapse

Unconfigured Ad Widget

Unconfigured Ad Widget Module
Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with text grabing.

    Sir, I am very new in php. Please help me about this. Suppose any visitor submited fb.com/xxx in input box. now how can I grab xxx in next page without fb.com? I think it will very easy for senior member. But hard to me. Please somebody help. At least give me a hints.

  • #2
    PHP Code:
    //users post example
    $post 'fb.com/sometext';

    //here we remove what we dont want
    //str_replace('THE TEXT YOU DONT WANT', 'TEXT YOU DO WANT(OR)LEAVE BLANK', $post);
    $post str_replace('fb.com/'''$post);

    //here we show new result which should display
    //sometext
    echo $post;
    //
    //
    //
    // 
    Last edited by Ghost; 15-07-12, 07:39. Reason: TO MAKE PHP CODE BOX BIGGER (STUPID BOX LOL)

    Comment


    • #3
      maybe this will help

      PHP Code:
      <?php
      $var 
      parse_url("http://fb.com/xxx?q=pov");

      print_r($var); // Array ( [scheme] => http [host] => fb.com [path] => /xxx [query] => q=pov )

      Comment


      • #4
        tanx it helpful. but what if a user insert "Ghost Vinay" as a name and i want to get the last surname how do i go about that?

        Added after 10 minutes:

        2) what if u want to get the last 3 letters of a word, eg "GHOST" and i want to get only the "OST" and/or the first 2 words also eg "GH"
        Last edited by Wintch; 17-07-12, 02:39.

        Comment


        • #5
          Originally posted by Wintch View Post
          2) what if u want to get the last 3 letters of a word, eg "GHOST" and i want to get only the "OST" and/or the first 2 words also eg "GH"
          I think this is just the thing u wanted: PHP.NET Function Substr

          PHP Code:
          <?php
          $rest 
          substr("ghost", -1);    // returns "t"
          $rest substr("ghost", -2);    // returns "st"
          $rest substr("ghost", -31); // returns "o"
          ?>

          Comment


          • #6
            tanx man, it help

            Comment

            Working...
            X