Jump to content

Recommended Posts

I have a variable that contains a string. I need to search for a word in the variable if that word is present I need to make a new variable that contains a different part of that string can anyone help me with this? I hope I don't have to use regex.


$fp = [Querying whois.arin.net] [Redirected to whois.ripe.net:43] [Querying whois.ripe.net] 

I want to check to see if the word "Redirected" is in the variable.

if (strpos($fp,"Redirected") is true){

  $newserver =  I need to get the string that is within the quotes  [Querying whois.arin.net] [Redirected to whois.ripe.net:43] [Querying "whois.ripe.net"] 
}

Link to comment
https://forums.phpfreaks.com/topic/153201-find-string-from-variable/
Share on other sites

that looks like it will work but what about getting assigning part of that string to a new variable.  so if the string is    "[Querying whois.arin.net] [Reirected to whois.ripe.net:43] [Querying whois.ripe.net]"

 

I need the data between the second instance of the word Querying to the 6th instance of the "]" symbol.

6th instance, I only see 3...  Sorry, I don't understand what that mean.  Can you give an example?

 

sorry i was counting both "[" and "]"

 

I need something like this

$fp = "[Querying whois.arin.net] [Reirected to whois.ripe.net:43] [Querying whois.ripe.net]";

$newfp = (getstring($fp,between 2nd Querying and 3rd ]);

echo $newfp;

output    whois.ripe.net

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.