11.12.2013, 20:10
(
Последний раз редактировалось Emmet_; 11.12.2013 в 21:08.
)
Script Indentation
Introduction
This is just a VERY simple PHP script that indents any text that's inputted into the text box. I'm slightly inexperienced with PHP since I'm a beginner, so that's why it looks like shit.
How it works
It works by automatically inserting 4 spaces in front of each unindentated piece of code - or tries to fix it. Also works well with opening braces.
I can't get this to work for some reason:
But I'm trying to make it work. It shouldn't be hard, since it works with other code, right?
Images
Since my web host is down, I only have images, sorry.
Which then outputs the following code after pressing the 'Indent' button:
It also works tough on multiple opening braces!
Output:
Download
indent.zip
If I did anything wrong, please point it out! I'm planning on learning more about PHP and I want to know what's right - thank you!
Introduction
This is just a VERY simple PHP script that indents any text that's inputted into the text box. I'm slightly inexperienced with PHP since I'm a beginner, so that's why it looks like shit.
How it works
It works by automatically inserting 4 spaces in front of each unindentated piece of code - or tries to fix it. Also works well with opening braces.
I can't get this to work for some reason:
pawn Код:
new
a,
b,
c;
Images
Since my web host is down, I only have images, sorry.
Which then outputs the following code after pressing the 'Indent' button:
pawn Код:
public OnPlayerConnect(playerid)
{
if (IsPlayerNPC(playerid))
{
return 1;
}
else
{
SendClientMessageToAll(-1, "Wow, a player connected!");
}
return 1;
}
Output:
pawn Код:
public OnPlayerConnect(playerid)
{
if (TestIndentation())
{
if(TestIndentation())
{
if(TestIndentation())
{
if(TestIndentation())
{
}
}
}
}
return 1;
}
indent.zip
If I did anything wrong, please point it out! I'm planning on learning more about PHP and I want to know what's right - thank you!