0

我想从数据库中获取部分价值,
我知道我必须使用拆分代码,但它会从 php 中删除,
所以我必须使用我现在
拥有的

<html>
<header>
<body>
<?php
$value = "10-20-30-40-50-87";
//i want to get 30 for example
?>

我知道我可以使用

$aryStr = split("#", $string); 
 print "$aryStr[0]<br>";
 print "$aryStr[1]";   

但它在 php5.3 中给了我一个错误,
所以我现在必须使用什么来从 value 中获取 40

4

1 回答 1

1

使用PHP 的 explode函数将 $value 拆分为一个字符串数组。

$value = "10-20-30-40-50-87";
$pieces = explode("-", $value);
echo $pieces[0]; // 10
echo $pieces[1]; // 20
于 2012-12-13T02:58:07.990 回答