Forum Moderators: coopster
I need to append data to the beginning and end of a string.
$string = $data1 . "your string" . $data2;
A find and replace function.
str_replace [us3.php.net]
And a function that counts the number of lines (or number of returns) in a document.
I don't know of one but it wouldn't be that hard using some filesystem [us3.php.net] and string [us3.php.net] functions.
As far as appending data before and after a string, it is a little more complex than just one string.
There will be a list of items that need IDs added to the front and end of each one.
So...
$list = "item1
item2
item3
item4";
AND it needs to look like this after processing:
$list = "id-item1-id
id2-item1-id2
id3-item1-id3
id1-item2-id1
id2-item2-id2
id3-item2-id3
etc...";
So I need to break this list into individual items, then append the id data (3 different versions for each item) and then return the result to a variable.
Also, is there a function that will find a word in a list and instead of replacing simplt add a modified version to the list?
Thanks!
See preg_replace and preg_replace_all functions.
Alternatively you could use a combination of native string functions to accomplish this but I suspect it would end up being a lot less efficient.