Hi guys am having a problem with a split(),i retrieve line from the text file
and i wanna split that line.i manage to split two words but splitting the string
enclosed on brackets it seems to be a problem to me. can someone look at my code and please help me maybe i am missing something.
the below is the one that i wanna split()
"1980" (5 dec 1234) shadee codes (1234)
i am looking to achive the following results
"1980"
(5 dec 1234)
shadee codes
(1234)
and i wanna split that line.i manage to split two words but splitting the string
enclosed on brackets it seems to be a problem to me. can someone look at my code and please help me maybe i am missing something.
Code:
<?php
$q=$_POST['path'];
$jaar=$_POST['years'];
$day=$_POST['day'];
//echo $day."<br />";
$month=$_POST['month'];
//echo $month."<br />";
$co= $_POST['coAbr'];
$num=$_POST['Number'];
$lineNumbers;
$lineNumber;
if($_POST['Number'])
{
// open the file
$file =$q."file1.txt";
// patterns to serch the file
$preg = "\[$jaar\] $co $num;";
//echo"the preg is:".$preg."<br />";
$data=stripslashes($preg);
$lines = file($file);
$count;
if ($lines)
{
foreach($lines as $lineNumber)
{
$lineNumbers++;
$foundAMatch = preg_match("/$preg/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);
if ($foundAMatch > 0)
{
$found = $matches[0][0];
$count=$lineNumber;
echo"The line number is : ".$lineNumber."<br />";
echo"The court name is:".$_POST['courtAbr']."<br />";
echo"Line from the Registry.<br /> ";
$words = split(" ", $lineNumber);
echo "File name is : ".$words[0]."<br />";
$lenth = strlen($words[0]) ;
$lineNumber1= substr($lineNumber , $lenth);
echo "The Line number one is : ".$lineNumber1."<br />";
$words4 = split(")", $lineNumber1);
$lenth4 = strlen($words4[0]) ;
echo "the lenth :".$lenth4."<br />";
echo "File name is : ".$words4[0]."<br />";
$lineNumber2= substr($lineNumber1 , $lenth4);
echo "the line num :".$lineNumber2."<br >";
$words5 = split(")", $lineNumber2);
echo $words5[0]."<br />";
}
}
}
}
?>
"1980" (5 dec 1234) shadee codes (1234)
i am looking to achive the following results
"1980"
(5 dec 1234)
shadee codes
(1234)
Comment