Help Me Please

Started on the old forum in April 2012 · view the original in the archive · old links redirect here

5 replies · 371 views · started 14 years ago · 1 min read

2 participants
Lue_chin Developer · 107 posts #1

hello experts i try to make a code but its not working i make a grabber of sms and i want that all the sms in this page simply copy on my own server and i try a code which not working please fix this code errors

{ 
    $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w); 

$sms=$w[1];

$name= var_export(substr($sms, 0, 20), true).PHP_EOL;
$name=str_replace('\'','',$name);

$myFile = "sms/".$name.".txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "".$sms."-\n";
fwrite($fh, $stringData);
fclose($fh);

 }

please help me

something else Fellow · 2,296 posts #2

debug it to find your error eg:

{  
    $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);  

$sms=$w[1]; 
print "Debug1: ".$sms."<br/>";

$name= var_export(substr($sms, 0, 20), true).PHP_EOL; 
print "Debug2: ".$name."<br/>";
$name=str_replace('\'','',$name); 
print "Debug3: ".$name."<br/>"; //etc
$myFile = "sms/".$name.".txt"; 
$fh = fopen($myFile, 'w') or die("can't open file"); 
$stringData = "".$sms."-\n"; 
fwrite($fh, $stringData); 
fclose($fh); 

 } 
Lue_chin Developer · 107 posts #3

ok i will another method

something else wrote: debug it to find your error eg:

{  
    $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);  

$sms=$w[1]; 
print "Debug1: ".$sms."<br/>";

$name= var_export(substr($sms, 0, 20), true).PHP_EOL; 
print "Debug2: ".$name."<br/>";
$name=str_replace('\'','',$name); 
print "Debug3: ".$name."<br/>"; //etc
$myFile = "sms/".$name.".txt"; 
$fh = fopen($myFile, 'w') or die("can't open file"); 
$stringData = "".$sms."-\n"; 
fwrite($fh, $stringData); 
fclose($fh); 

 } 

hello sir please make this again because its not working fine it code not make no one files

Added after 5 minutes:

hello sir i have another option to make files can we paste the all lines according to us for ex : if lines are i am the best i am the bad i am the king i am the poor matlab je sabhi files wo mere according rakhe means agar main 1 hi paste krana chata hun to 1 paste ho aur agar 2 to 2 is code meain kujh ho sakta hai ese

$chunk = explode('<td class="pl10">', $page); 
//print_r($chunk); 
$count = count($chunk); 
for ($i=1; $i < $count; $i++)  
{   
    $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk, $w);   

echo $w[1]; 
echo"<br />
";
echo $w[2];echo"<br />
";
echo $w[3];echo"<br />
";
echo $w[4];echo"<br />
";
echo $w[5];
echo $w[6];

 } 
something else Fellow · 2,296 posts #4

sorry i cant understand what you want maybe something like:

$chunk = explode('<td class="pl10">', $page);     
for ($i=1; $i < count($chunk); $i++)   
{    
    preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);   
    for ($a=0; $a < count($w); $a++)   
    { 
        echo $w[$a]."<br />"; 
    }
 } 
Lue_chin Developer · 107 posts #5

something else wrote: sorry i cant understand what you want maybe something like:

$chunk = explode('<td class="pl10">', $page);     
for ($i=1; $i < count($chunk); $i++)   
{    
    preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);   
    for ($a=0; $a < count($w); $a++)   
    { 
        echo $w[$a]."<br />"; 
    }
 } 

i explain what i want i want that there is 10 lines which i pick but i want to show only 5 or 6 files and its with another location means 1 lines place to 5th and 3 to 1st this type so i want to arrange all files according to me and this method i make text files in my server

something else Fellow · 2,296 posts #6

then you would change the variables on this line:

for ($a=0; $a < count($w); $a++) 

to what ever you wanted eg: lines 3 to 5 would be:

 for ($a=3; $a < 6; $a++)

if you didnt want line 4 included in that then you would use a simple "if" statement eg:

for ($a=3; $a < 6; $a++)    
    {  
        if($a!=4)
        echo $w[$a]."<br />";  
    }

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close