nostalgy - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of nostalgy.php
- <?php
- $str="))";
- $i=0;
- $stack=array();
- $top=-1;
- $flag=true;
- while ($i<strlen($str)){
- if ($str[$i]=='(' || $str[$i]=='{' ||$str[$i]=='[')
- {
- $top++;
- $stack[$top]=$str[$i];
- }
- else {
- if ($top==-1) {echo 'NO'; $flag=false;break; }
- if (($str[$i]==')' && $stack[$top]=='(') ||($str[$i]=='}' && $stack[$top]=='{') ||($str[$i]==']' && $stack[$top]=='['))
- $top--;
- else{
- echo 'NO'; $flag=false;break; }
- }
- $i++;
- }
- if ($flag==true && $top==-1)
- echo 'YES';
- else
- echo 'NO';