Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

funkcija ekvivalentna "explode" u php-u?

[es] :: Pascal / Delphi / Kylix :: funkcija ekvivalentna "explode" u php-u?

[ Pregleda: 2530 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Član broj: 32202
Poruke: 4391
*.gw-1.bg.krstarica.net.

Sajt: https://avramovic.info


+46 Profil

icon funkcija ekvivalentna "explode" u php-u?03.10.2005. u 22:26 - pre 225 meseci
da li ima neka funkcija a da je nekako... elegantna... kojom odradish:

Code:
neki_array := explode(' ','Avram je ... Avram'); //glup primer, al' shta tju


i onda dobijesh:

neki_array[0] = 'Avram';
neki_array[1] = 'je';
neki_array[2] = '...';
neki_array[3] = 'Avram';

po mogucstvu da prvi parametar bude string, ali ako ne mozhe, onda nek bude i char ;)
Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
Odgovor na temu

Srki_82
Srdjan Tot
Me @ My Home
Ljubljana

Član broj: 28226
Poruke: 1403
82.208.201.*

ICQ: 246436949


+10 Profil

icon Re: funkcija ekvivalentna "explode" u php-u?03.10.2005. u 22:39 - pre 225 meseci
Code:
var
  S: TStringList;
begin
  S := TStringList.Create;
  S.Delimiter := ' ';
  S.DelimitedText := Edit1.Text;
  // S[0] je prva rec
  // S[1] druga... itd
  S.Free;
end;

 
Odgovor na temu

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Član broj: 32202
Poruke: 4391
*.sbb.co.yu.

Sajt: https://avramovic.info


+46 Profil

icon Re: funkcija ekvivalentna "explode" u php-u?03.10.2005. u 23:02 - pre 225 meseci
God bless you Srki ;)
Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
Odgovor na temu

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Član broj: 32202
Poruke: 4391
*.yu1.net.

Sajt: https://avramovic.info


+46 Profil

icon Re: funkcija ekvivalentna "explode" u php-u?04.10.2005. u 18:08 - pre 225 meseci
evo u obliku procedure:
Code:

procedure TForm1.explode(var list:TStringList;delimiter:char;text:string);
begin
  list.Delimiter := delimiter;
  list.DelimitedText := text;
end;


koriscenje:
Code:

procedure TForm1.FormCreate(Sender: TObject);
var lista:TStringList;
    loop:integer;
begin
  lista:=TStringList.Create;
  explode(lista,' ','testing explode procedure');
  for loop := 0 to lista.Count-1 do ShowMessage(lista[loop]); //ovo je samo testiranje
end;


i u obliku funkcije:
Code:
function explode(delimiter:char;text:string):TStringList;
begin
Result := TStringList.Create;
Result.Delimiter:=delimiter;
Result.DelimitedText:=text;
//Result.Free; //ako ostavim result.free onda ne dobijam nishta tako da sam to izbacio ali ne znam da li smeta ishta???
end;


...i tako... ;)

koriscenje:
Code:
procedure TForm1.FormCreate(Sender: TObject);
var lista:TStringList;
    loop:integer;
begin
  lista:=TStringList.Create;
  lista:=explode(' ','testiranje explode funkcije');
  for loop := 0 to lista.Count-1 do ShowMessage(lista[loop]); //ovo je samo testiranje
end;

Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
Odgovor na temu

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Član broj: 32202
Poruke: 4391
194.106.174.*

Sajt: https://avramovic.info


+46 Profil

icon Re: funkcija ekvivalentna explode u php-u?23.02.2007. u 22:53 - pre 208 meseci
Evo mnogo elegantnijih funkcija, izvukoh ih sa delphi3000 Pa ako nekome zatreba...

Opet mi je trebalo ovo a ova gore rešenja nisu baš najsrećnija.

Code:
//////////////////////////////////////////////////////////////////////////
// Procedure - implode
// Author    - Ronald Buster
// Remarc    - PHP like implode function
//
// Returns a string containing a string representation of all the array
// elements in the same order, with the glue string between each element.
//////////////////////////////////////////////////////////////////////////

function implode(const glue: string; const pieces: array of string): string;
var I: Integer;
begin
  Result := '';
  for I := 0 to High(Pieces) do
    Result := Result + Glue + Pieces[I];
  Delete(Result, 1, Length(Glue));
end;

//////////////////////////////////////////////////////////////////////////
// Procedure - explode
// Author    - Ronald Buster
// Remarc    - PHP like explode function
//
// Returns an array of strings, each of which is a substring of string
// formed by splitting it on boundaries formed by the string separator.
// If limit is set, the returned array will contain a maximum of limit
// elements with the last element containing the rest of string.
//
//////////////////////////////////////////////////////////////////////////

function explode(const separator, s: string; limit: Integer = 0): TDynStringArray;
var SepLen: Integer;
    F, P: PChar;
begin
  SetLength(Result, 0);
  if (S = '') or (Limit < 0) then
    Exit;
  if Separator = '' then
    begin
      SetLength(Result, 1);
      Result[0] := S;
      Exit;
    end;
  SepLen := Length(Separator);

  P := PChar(S);
  while P^ <> #0 do
    begin
      F := P;
      P := AnsiStrPos(P, PChar(Separator));
      if (P = nil) or ((Limit > 0) and (Length(Result) = Limit - 1)) then
        P := StrEnd(F);
      SetLength(Result, Length(Result) + 1);
      SetString(Result[High(Result)], F, P - F);
      F := P;
      while (P^ <> #0) and (P - F < SepLen) do
        Inc(P);
    end;
end; 

Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
Odgovor na temu

morlic
Milos Orlic
Beograd

Član broj: 6081
Poruke: 735
*.dynamic.sbb.co.yu.



+1 Profil

icon Re: funkcija ekvivalentna "explode" u php-u?23.02.2007. u 23:20 - pre 208 meseci
Evo jos jednog linka:

http://www.jasonwhite.co.uk/?p=31
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: funkcija ekvivalentna "explode" u php-u?

[ Pregleda: 2530 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.