Help with text grabing.

Started on the old forum in July 2012 · view the original in the archive · old links redirect here

5 replies · 596 views · started 14 years ago · 1 min read

5 participants
Habib1121 Newbie · 1 posts #1

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.

Ghost Senior · 366 posts #2
//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;
//
//
//
//
<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
ionutvmi Junior · 45 posts #3

maybe this will help

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

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

PIMP-WAP.NET - PIMP YOUR MOBILE

MASTER-LAND.NET - WAPMASTERS LAND

Wintch Developer · 68 posts #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:

  1. 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"
asifnayem Developer · 119 posts #5

Wintch wrote: 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
$rest = substr("ghost", -1);    // returns "t"
$rest = substr("ghost", -2);    // returns "st"
$rest = substr("ghost", -3, 1); // returns "o"
?>
Wintch Developer · 68 posts #6

tanx man, it help

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close