Skocz do zawartości

Rekomendowane odpowiedzi

Opublikowano

Czesc, mam pytanko, jak zrobic skracanie tekstu, np:

 

zmienna1 = 'https://gmclan.org/index.php?czytajart=7'

 

i aby pobrano tylko - index.php?czytajart=7 - ta czesc linku?

Opublikowano

Nie, o to:

GML
str = 'https://gmclan.org/index.php?czytajart=7';

 

if( string_pos( 'http://', str ) )

{

str = string_delete( str, 1, 7 );

slash = string_pos( '/', str );

if( slash )

{

host = string_copy( str, 1, slash - 1 );

file = string_delete( str, 1, slash );

}

else

{

host = str;

file = 'index.php';

}

}

I wtedy tylko używać string_replace na zmiennej file.
GML
file = string_replace( file, 'costam', 'cos/cos' );

 

Przy okazji znalazł się bug w parserze GML.

 

EDIT

Jeśli dalej to mało to można sobie rozbić cały URL na części:

GML
str = 'https://gmclan.org/dir1/dir2/index.php?czytajart=7';

 

if( string_pos( 'http://', str ) )

{

str = string_delete( str, 1, 7 );

slash = string_pos( '/', str );

if( slash )

{

host = string_copy( str, 1, slash - 1 );

str = string_delete( str, 1, slash );

 

fileSize = 0;

 

while( true )

{

slash = string_pos( '/', str );

if( slash )

{

file[fileSize] = string_copy( str, 1, slash - 1 );

fileSize += 1;

str = string_delete( str, 1, slash );

}

else

{

file[fileSize] = str;

fileSize += 1;

break;

}

}

}

else

{

host = str;

file[0] = 'index.php';

fileSize = 1;

}

}

I wtedy jest fajnie.

 

Dorobić jeszcze odczyt tego co jest przekazywane przez GET?

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...