function get_user_info($filename, &$list) { $file = fopen($filename, "r") or die($filename); // echo "cannot open file"; global $bad_word_list; // = get_words_list (); global $root_folder; if ($file) { while (($line = fgets($file)) !== false) { // process the line read. $tmp_object = json_decode($line, true); // print_r ( $tmp_object ); // $tmp_item = ( array ) $tmp_object; // echo $tmp_item ['user'] ->id_str; try { /* * if ($tmp_item ['user']->id_str != null && array_key_exists ( $tmp_item ['user']->id_str, $list ) == false) { * $list [$tmp_item ['user']->id_str] = array (); * $list [$tmp_item ['user']->id_str] ['messages'] = array (); * $list [$tmp_item ['user']->id_str] ['messages_no'] = 0; * $list [$tmp_item ['user']->id_str] ['bad_words'] = array (); * $list [$tmp_item ['user']->id_str] ['bad_words_no'] = 0; * $list [$tmp_item ['user']->id_str] ['weight'] = 0; * * // $tmp_item = (array)$tmp_item ['user']; * array_push ( $list [$tmp_item ['user']->id_str] ['messages'], $tmp_item ['text'] ); * $mess_no = $list [$tmp_item ['user']->id_str] ['messages_no']; * $list [$tmp_item ['user']->id_str] ['messages_no'] = $mess_no + 1; * * $bad_word_no = $list [$tmp_item ['user']->id_str] ['bad_words_no']; * $list [$tmp_item ['user']->id_str] ['bad_words_no'] = $bad_word_no + count_bad_word_in_message ( $bad_word_list, $tmp_item ['text'] ); * * } */ write_user_info($tmp_object['user']['id_str'], $line, $root_folder); } catch (Exception $e) { echo $filename; } /* * if ($tmp_item ['text'] != null) { * $item = array (); * // $item ['created_at'] = ( array ) $tmp_item ['created_at']; * $tmp = ( array ) $tmp_item ['geo']; * $item = ( array ) $tmp ['coordinates']; * array_push ( $array, $item ); * } */ } // echo json_encode ( $list ); fclose($file); } else { // error opening the file. } }
function get_user_info($filename, &$list) { $file = fopen($filename, "r") or die($filename); echo $filename; global $bad_word_list; // = get_words_list (); global $root_folder; if ($file) { while (($line = fgets($file)) !== false) { // process the line read. $tmp_object = json_decode($line, true); // print_r ( $tmp_object ); // $tmp_item = ( array ) $tmp_object; // echo $tmp_item ['user'] ->id_str; try { echo $line; write_user_info($tmp_object['user']['id_str'], $line, $root_folder); } catch (Exception $e) { echo $filename; } } // echo json_encode ( $list ); fclose($file); } else { // error opening the file. } }