0

I work on some php project for university. Need to create simple PHP chat client. I done that but in response file that do me split of string I have this message:enter image description here

I tried to change with explode() but it still gives me same error. Restarted apache and cleaned but still have same error. Can somebody tell me what is catch to solve this.

My response.php file is:

<?php
$lastreceived=$_POST['lastreceived'];
$room_file=file("room1.txt",FILE_IGNORE_NEW_LINES);
for($line=0;$line<count($room_file);$line++){
$messageArr=str_split("<!@!>",$room_file[$line]);
if($messageArr[0]>$lastreceived)echo $messageArr[1]."<br>";
}
echo "<SRVTM>".$messageArr[0];
?>
hakre
  • 193,403
  • 52
  • 435
  • 836
Akosha
  • 471
  • 1
  • 10
  • 24
  • 2
    If it's still complaining about `split()`, you edited the wrong file. Changes in PHP code will usually show up immediately, no server restart should be necessary. – Pekka Nov 25 '12 at 17:26
  • 1
    What you see is _not_ an error, it is a notice what you are using a function that might be missing in future releases of php. Such notice is only displayed if you tell php to do so. So for production sites you want to disable visualization of notices and the like. You can configure that behaviour inside your `php.ini` file. – arkascha Nov 25 '12 at 17:30
  • ok... will try to edit php.ini – Akosha Nov 25 '12 at 17:31
  • 1
    show us receive.php .. because there is the split call –  Nov 25 '12 at 17:33

1 Answers1

1

Use preg_split instead.

array preg_split ( string $pattern , string $subject [, int $limit = -1 [, int $flags = 0 ]] )

In your case:

preg_split ("/<!@!>/",$room_file[$line]);
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225