700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > php把txt文本转换成数组并保存数据库

php把txt文本转换成数组并保存数据库

时间:2018-12-27 15:52:01

相关推荐

php把txt文本转换成数组并保存数据库

php教程|php手册

php,把,txt,文本,转,换成,数组,并,保存,数据库,今天,一个,工作,要做,就,是把,一个,达,万条,记录

php教程-php手册

今天有一个工作要做就是把一个达5万条的记录的txt 文件的内容要保存到数据库,开始想到用file_get_contents后来就看到可以用file更简单,下面是我写的程序.

爱调查源码,ubuntu查询系统信息,tomcat服务不展示验证,爬虫3.3 下载,上海php商城系统订制,幽灵SEOlzw

<?php

include_once(‘../inc/connect.php’);

class fso_getline{

var $filename =’number.txt’;

var $content;

var $arr;

语言翻译器在线 源码,Ubuntu终端创建组,有两个网卡 tomcat,网络爬虫的需求,哪里可以找到php技术学习,seo商铺标题lzw

function read_line(){

二手车交易网站源码,vscode fuwuqi,ubuntu 4g 内存,tomcat重启如何不被监控到,sqlite 通知 程序,sublime网页设计,创建ftp服务器后连接不上,input表单验证插件,成型前端ui框架,爬虫美女图,php获取客户端mac地址,牛seo,网站接入支付宝需要网站备案吗,盗取网页代码的软件,wordpress最新模板,jq页面显示加载中,asp公文管理系统,视频类小程序源码lzw

if(file_exists($this->filename) ){

$this->content =file($this->filename);

if(is_array($this->content)){

$this->arr =$this->content;

}else{

$this->error(1);

}

}else{

$this->error(0);

}

}

function array_to_database(){

foreach( $this->arr as $temp ){

echo $temp,’

‘;

$this->sava_data($temp);

}

}

function sava_data($cd){

$sql =”Insert into wk_card(card_id) value(‘$cd’)”;

mysql_query($sql);

}

/*

如何使用file_get_contents()函数就要用到下面的转换

function into_array(){

$temp =str_replace(chr(13),’|’,$this->content);

$this->arr =explode(‘|’,$temp);

}

测试输出数组函数

function echo_array(){

print_r($this->arr);

}

*/

function error($id){

$error_array =array(‘file not exists’,’file unload’);

echo $error_array[$id];

}

}

类的调用方法

$test =new fso_getline();

$test->read_line();

$test->array_to_database();

?>

最后申明一下本站原创转载注明: /phper/php.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。