I currently have a file path (Such as “/home/type_04/domain.com/account_30531134/plate” or “/home/type_02/newdomain.net/account_80233144/subdomain.newdomain.net/plate”).
I wish to strip out the “account_xxxxx” and everything before it from the path. I do not know how to approach this, since the “type”, “domain”, and “account_xxxxx” sections are different in each path. I currently have the “before” path saved to one variable and wish to save the “after” portion to a different one.
Additionally, I wish to save only the “type” section as a third variable.
Thanks for that response. The "strstr” function looks closest to what I want, however, since the “account” section changes, I do not know how it would work.
Also, is there is a better way to get just the “type” section out of there?
Unfortunately, the “type”, “domain”, and “account” variables are randomly generated (Or inputted by the user however they wish), and I have no way to predict what they might be.
So the block below will not work unfortunately.
Also, I wish to be able to echo a single variable to show only the “type” or ending (Everything after the account variable) separately.
Example:
<?php
$pathone = '/home/type_04/domain.com/account_30531134/plate';
$pathtwo = '/home/type_02/newdomain.net/account_80233144/subdomain.newdomain.net/plate';
$pathoneending = //Some Code here to get "/plate"
$pathtwoending = //Some Code here to get "/subdomain.newdomain.net/plate"
$pathonetype = //Some Code here to get "type_04"
$pathtwotype = //Some Code here to get "type_02"
echo $pathoneending;
echo $pathtwoending;
echo $pathonetype;
echo $pathtwotype;
?>
His routine put those in an array called $results. If you need them in individual variables, just move them in like:
$pathoneending = $results[1];
$pathonetype = $results[2];