PHP获取第一个数字

PHP获取第一个数字,php,Php,如何从函数中获取第一个数字?我要查一下有多少号码 $numbers=1,2,3; 因此,我的输出需要是1是第一个数字,3个数字,您可以在下一个示例中尝试。用于拆分文本: <?php $numbers = "1, 2, 3"; $array = explode(', ', $numbers); echo $array[0]." is the first number, ".count($array)." numbers"; ?> 如果使用数组而不是字符串,则会容易得多: $numb

如何从函数中获取第一个数字?我要查一下有多少号码

$numbers=1,2,3;
因此,我的输出需要是1是第一个数字,3个数字,您可以在下一个示例中尝试。用于拆分文本:

<?php
$numbers = "1, 2, 3";
$array = explode(', ', $numbers);

echo $array[0]." is the first number, ".count($array)." numbers";
?>

如果使用数组而不是字符串,则会容易得多:

$numbers = array (8, 32, 83);
echo $numbers[0]." is first number, ";
echo count($numbers)." numbers";

你没有任何功能。你有一根绳子。如果您有一个字符串,请在其上使用explode来获取数字。tipp读取PHP文档=>的可能副本
$numbers = array (8, 32, 83);
echo $numbers[0]." is first number, ";
echo count($numbers)." numbers";