PHP limit length of every string in array

前端 未结 3 1398
名媛妹妹
名媛妹妹 2021-01-16 20:26

I have an array with multiple strings, like this:

$str[0] = \"kasdnkjsandjabsdkjsbad\";
$str[1] = \"kasdnkjsandjasdjksabdjkasbkjdsak\";
$str[2] = \"kasdnkjsa         


        
3条回答
  •  醉梦人生
    2021-01-16 21:08

    I am assuming you want to iterate through each string in the array and trim it to a specific length.

    Create a function that does this to a single string (as an argument). Use array_map to apply this function to each element in the array.

    Try this yourself - if you have any problems, append your attempt to your question.

提交回复
热议问题