Php fwrite help :d

Started on the old forum in March 2013 · view the original in the archive · old links redirect here

2 replies · 419 views · started 13 years ago · 1 min read

2 participants
Christian Cepe Newbie · 7 posts #1

Help with my code. I want to remove the specific line in a txt file.

urls.txt

AAAB0Ei5vrDEBAEtq2YkZAQLaM8hjVkYZAW9Mp18EXX7aQiXvN4doWI5ZCxtmZCTUxqMKpS4M5VdPnTTv17P5UAcJ1sISfcikRkZBtZBUHHBC1bC0150AkY
AAAB0Ei5vrDEBAAiULULE75kZBFmAOpRoX6eCXjANxhZARgOaHAbPWrHezuXI0kjTlNp9ZACu2UpSmVoZAl6kvSPCSREVMqEECBnmqNl7hC4CII8aML0r
AAAB0Ei5vrDEBAM5g2xRtxFPaUNHGs5JQynt3H75l3j1CG0Kt8oroZCCiYZCkyMsySAGoHhm02syZA5Xl02976Q06NANbls8LxGMWFWCUhaLmDcCGW5M 
AAAB0Ei5vrDEBAFdKM3SZCitxYupspNFCKObBTATsGtsOerZAZB7YKxqfF49OiZBdScOYbRDn73AWqzRCj3sAlhIgG2QQzfCSCSBZCRAeOpIyEEdI7nqRZAWEW

I want to remove the line AAAB0Ei5vrDEBAEtq2YkZAQLaM8hjVkYZAW9Mp18EXX7aQiXvN4doWI5ZCxtmZCTUxqMKpS4M5VdPnTTv17P5UAcJ1sISfcikRkZBtZBUHHBC1bC0150AkY

Can you help me? THANKS!

<?php
$file = fopen("urls.txt", "r");
$i = 0;
while (!feof($file)) {
    $fb[] = fgets($file);
}
fclose($file);
foreach ($fb as $access_token){
$url="https://graph.facebook.com/me?fields=name&access_token=" . $access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);	
$cJSON = curl_exec($ch);
$feed=json_decode($cJSON, true);
$fbcomments = $feed["error"]["type"];

if($fbcomments=="OAuthException")
  {
echo "<s>" .$access_token, "</s><br/>";
///REMOVE LINE CODE	
  } 
else
  {
  echo "<b>" .$access_token, "</b><br />";
  }
}
?>
Ghost Senior · 366 posts #2

if you know that the string of text is always going to be the same you can simply just use str_replace() function.

example:

$url_variable = str_replace('AAAB0Ei5vrDEBAEtq2YkZAQLaM8hjVkYZAW9Mp18EXX7aQiXvN4doWI5ZCxtmZCTUxqMKpS4M5VdPnTTv17P5UAcJ1sISfcikRkZBtZBUHHBC1bC0150AkY', '', $url_variable);
//
//
//
//
<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Christian Cepe Newbie · 7 posts #3

Ghost wrote: if you know that the string of text is always going to be the same you can simply just use str_replace() function.

example:

$url_variable = str_replace('AAAB0Ei5vrDEBAEtq2YkZAQLaM8hjVkYZAW9Mp18EXX7aQiXvN4doWI5ZCxtmZCTUxqMKpS4M5VdPnTTv17P5UAcJ1sISfcikRkZBtZBUHHBC1bC0150AkY', '', $url_variable);
//
//
//
//

Thank you man.

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