Split string
Dividing a string into an array using the EXPLODE function
Copy Code code as follows:
<?php
$source = "HELLO1,HELLO2,HELLO3,HELLO4,HELLO5";//separating strings by commas
$hello = Explode (', ', $source);
for ($index =0; $index <count ($hello); $index + +)
{
echo $hello [$index];echo "</br>";
}
?>
Split function for character segmentation
The delimiter can be a slash, a dot, or a horizontal line
Copy Code code as follows:
<?php
$date = "04/30/1973";
List ($month, $day, $year) = Split (' [/.-] ', $date);
echo "Month: $month; Day: $day; Year: $year <br/>\n ";
?>
Code for multi-criteria query via array
Copy Code code as follows:
<?php
$keyword = "asp php,jsp";
$keyword =str_replace ("", "", $keyword);
$keyword =str_replace ("", ",", $keyword);
$keyarr =explode (', ', $keyword);
for ($index =0; $index <count ($keyarr); $index + +)
{
$whereSql. = "and (Arc.title like) $keyarr [$index]% ' Or arc.keywords like ' $keyarr [$index]% ')";
}
Echo $whereSql;