English 中文(简体)
计算购买力平价中的最后垂直长度
原标题:Calculate final tweet character length in PHP

批发者为信封内的所有环节设定了20年的固定性质长度。

So even if a user uses an url shortening service like bit.ly and pastes url shorter than 20 characters all urls will finally be given a length of 20 characters by twitter.

我很想知道,如何计算eet(包括一个或多个短ur)的最后长度,这样它就与PHP保持了140个特性。

最佳回答

You can replace your links with some generic text via regex and count the whole length with mb_strlen() afterwards. mb_strlen because Twitter counts Multibyte chars as one char.

$tweet =  Check this: http://stackoverflow.com/questions/8864767/calculate-final-tweet-character-length-in-php ;
$length = mb_strlen(preg_replace( ~https?://([^s]*)~ ,  http://8901234567890 , $tweet),  UTF-8 );
var_dump($length); // int(32);

或许你必须调整比照(无效果园)的比照。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签