?PHP?,explode()
?????????????????,?????????????????????????????????explode()
??????:
- ??CSV??:?????CSV????????,????
explode()
???????????(,)??,??????explode()
???????????(;)???????????
$csv_data = "https://www.yisu.com/ask/name,age,city/nJohn,25,New York/nJane,30,Los Angeles"; $rows = explode("\n", $csv_data); foreach ($rows as $row) { $fields = explode(",", $row); // ????????? }
- ??URL??:??????URL???????,????
explode()
??????????&????,??????explode()
?????????=?????
$query_string = "name=John&age=25&city=New York"; $params = explode("&", $query_string); foreach ($params as $param) { list($key, $value) = explode("=", $param); // ????????? }
- ???????:???????????????,????
explode()
????????????????(?-?:?)???
$date_string = "2021-08-01"; $date_parts = explode("-", $date_string); list($year, $month, $day) = $date_parts;
- ??????:????????????????,????
explode()
???????????(=)???(:)???
$config_data = "https://www.yisu.com/ask/database_host=localhost/ndatabase_user=root/ndatabase_password=secret"; $lines = explode("\n", $config_data); foreach ($lines as $line) { list($key, $value) = explode("=", $line); // ?????????? }
????explode()
???????????,???,????????explode()
??????????????????????