Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <core>
- #include <float>
- public OnFilterScriptInit()
- {
- new Array[5][32];
- new string[64];
- new string2[64];
- strcat(string, "Pasta#lol#Zupa#lol#Kisiel#lol#Budyn#lol#Igrekzet");
- printf("String = %s", string);
- printf("Array[][] = pusty", string);
- print("Function: explode(string, array, \"#lol#\");");
- explode(string, Array, "#lol#");
- printf("Array[0] = %s", Array[0]);
- printf("Array[1] = %s", Array[1]);
- printf("Array[2] = %s", Array[2]);
- printf("Array[3] = %s", Array[3]);
- printf("Array[4] = %s", Array[4]);
- print("Function: implode(string2, array, \", \");");
- implode(string2, Array, ", ");
- printf("String2 = %s", string2);
- return 1;
- }
- explode(const string[], array[][], separator[], bool:caseignore = true, maxarray = sizeof array, maxarray2 = sizeof array[])
- {
- new pos = -1, pos2, idx, len = strlen(separator);
- while((pos = strfind(string, separator, caseignore, pos + 1)) && -1 != pos)
- {
- if(idx == maxarray)
- return 1;
- strmid(array[idx], string, pos2, pos, maxarray2);
- pos2 = pos + len;
- idx++;
- }
- if(!pos2)
- {
- strcat(array[0], string, maxarray2);
- return 1;
- }
- if(idx == maxarray)
- {
- return 1;
- }
- strmid(array[idx], string, pos2, strlen(string), maxarray2);
- return 1;
- }
- implode(string[], const array[][], separator[], maxstring = sizeof string, maxarray = sizeof array)
- {
- string[0] = EOS;
- for(new i = 0; i < maxarray; i++)
- {
- strcat(string, array[i], maxstring);
- if(i != maxarray - 1)
- {
- strcat(string, separator, maxstring);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement