![]() | | ||||||||
| | #1 |
| PHP Programmer Join Date: Apr 2007 Location: Chennai, Tamil Nadu, India.
Posts: 347
Thanks: 2
Thanked 0 Times in 0 Posts
|
Hi Warriors, For those of you who spin articles, it can be a total pain to correct articles when you leave out a closing '}' or there is a stray '|' in between. I've attached a script which allows you to check if an article has properly balanced opening and closing curly brackets. Do not run this on your server. Rename the file to tester.php. You have to install php in your computer and run it using command line. Copy this file to the directory containing the article text files and use the following syntax: php tester.php filename.txt If you see "perfect!" as the output - your article is perfectly balanced. If not, you will be given a list of lines where the starting brace is not closed or where there is a stray '|'. Hope you find it useful. Raja Sekharan |
| | |
| | #2 |
| Guest
Posts: n/a
|
This is the exact reason the system I use you do not have to type in any } - I personally like things more automative and when just clicking on a link adds the alternative for you it is a much better way to go... Hope your file helps those that still do manually type in } James |
|
| | #3 | |
| An Original Thinker War Room Member Join Date: Aug 2004 Location: Where Original Ideas Meet Action.
Posts: 3,584
Blog Entries: 1 Thanks: 594
Thanked 213 Times in 145 Posts
| Quote:
Same here. I just highlight and click a button. Job done. Glenn | |
| | ||
| | |
| | #4 |
| Warrior Member Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
Hi, Thanks Raja, this was helpful. There was a small error in the code which I corrected (see comments in code). Here's the script: Code: <?php
= ;
// = ;
= fopen(,"r");
= array();
=0;
0 = 0;
while (!feof())
{
= fgetc();
++;
if ( == "|" && 0<=0)
{
echo "Unexpected |.";
= array();
break;
}
if ( == "{")
{
array_push(,);
0++; // = 1;
}
if ( == "}")
{
if (count() == 0)
{
print "Excess } at nn";
= array();
break;
}
0--; // = 0;
array_pop();
}
}
fclose();
if (count() == 0 )
echo "perfect!";
= file_get_contents();
foreach ( as )
{
echo substr(,,100)."nn";
}
?> |
| | |
| | #5 |
| Senior Warrior Member War Room Member Join Date: May 2005 Location: , , .
Posts: 1,102
Thanks: 11
Thanked 36 Times in 22 Posts
|
Or...you can just use: Check Your Spintax Will highlight the open and close brackets for you and also tell you where your mistake is. Ben Shaffer |
| | |
| | |
| | #6 |
| Warrior Member Join Date: Feb 2012
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
|
I always thought that most spinners these days have an auto syntax checker. I know TBS does and SpinnerChief too. I suppose there are a plethora of other products out there though, and I always love me a good PHP script. Great share! |
| | |
| | #7 |
| Senior Warrior Member War Room Member Join Date: May 2005 Location: , , .
Posts: 1,102
Thanks: 11
Thanked 36 Times in 22 Posts
|
The problem with the built in checkers I found was that it was hard to actually find your mistakes and debug them. Especially when you are dealing with hundreds of articles like we are makes it far easier to be able to debug all in one place. Also, this deals with any type of spintax and (almost) unlimited nested levels. B |
| | |
| | |
![]() |
|
| Tags |
| article, checker, marketers, script, spun |
| |
![]() |