Jump to content

Skip characters in a <textarea> for output


cjbeck71081

Recommended Posts

I have a form i created that takes text entered in a <textarea> and adds some tags to it like this

 

Form1.html

<form action="test.php">

<textarea>http://us10.stupid.com/Myfile.jpg</textarea>

 

What i would like to do is remove the leading 11 characters from the variable and add some tags to it so it might look like this:

 

test.php

<php

$file = $POST_['textarea'];
((((trim $file by 11 characters from the left)))))
$file1 = "<img src='http://www.";
$totalfile = "$file1'>";

echo ($totalfile);

?>

 

So that it outputs

http://www.stupid.com/Myfile.jpg

 

 

Any help is appreciated.

 

Thank You

Chris Beck

 

Link to comment
Share on other sites

Thanks guys but now to throw a wrench, (and there may not be a way of doing this) the server changes sometimes from

 

http://us10.server.com/jioasfjdasda.jpg

 

to

 

http://us2.server.com/jaksdfasa.jpg

 

but the www.server.com always works

 

so the substr works to eliminate the first 11 characters in the us10 one.  Is there any way to put a clause in that will allow for it to remove 10 characters if it a certain setup.  Possibly a "like" clause or something, i dont know.

 

Thanks for the help.

 

 

Link to comment
Share on other sites

oh pishposh... lol... no need for a like statement :-) just use this :-)

 

<?php
function get_ending($filepath){ 
return substr($filepath, strpos($filepath, strchr($filepath, ".")));
}

$file = 'http://us10.stupid.com/Myfile.jpg';
$file = 'http://www' . get_ending($file);
echo $file;
?>

not tested... but it should work :D

Link to comment
Share on other sites

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.