splliting text
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'd try something like this. Not tested, but if my brain analyzed it correctly it should work.
PHP код:
new
    
originalString[] = "Text1\nText2\nText3";
new
    
posStart = -1,
    
posEnd 0,
    
index 0,
    
destination[5][110]; // maximum 5 splits
new i;
while(
originalString[i++] && index sizeof(destination)) // loop original string until end or until destination is full
{
    
// found linefeed
    
if(originalString[i] == '\n' || originalString[i] == EOS)
    {
        if(
posStart posEnd)
        {
            
posStart i;
        }
        else
        {
            
posEnd i;
        }
        if(
posEnd posStart)
        {
            
strmid(destination[index], originalStringposStartposEndsizeof(destination[]));
            
index++;
        }
    }

Thanks so much sir
+repped

Edit: it says you must spread some reputation around... so sorry sir
Reply


Messages In This Thread
splliting text - by Zorono - 02.09.2017, 17:40
Re: splliting text - by Vince - 02.09.2017, 17:59
Re: splliting text - by Zorono - 02.09.2017, 19:13
Re: splliting text - by SyS - 03.09.2017, 02:25
Re: splliting text - by Paulice - 03.09.2017, 04:14

Forum Jump:


Users browsing this thread: 1 Guest(s)