我将这些字符串保存在我的mysql数据库中,格式如下:
/uploads/attachments/18/105/WordPress_3_Cookbook.pdf
Run Code Online (Sandbox Code Playgroud)
现在,我只需要获取文件名.
我想我需要PHP中的一些函数,从后面检查字符串,并获得第一个斜杠的所有内容.
怎么写这样的东西?
这是我在我的localhost上运行良好的代码:
<?php
$list = array();
array_map(function($var){}, $matches_array_1);
foreach ( $matches_array_1 as $value ) {
$key = $value['team'];
if (array_key_exists($key, $list)) {
$list[$key]['team_points'] += $value['team_points'];
$list[$key]['team_occurrences'] ++;
} else {
$list[$key] = $value;
$list[$key]['team_occurrences'] = 1;
}
}
usort($list ,function($a, $b){ $a = $a['team_points'] ; $b = $b['team_points'] ; return ($a == $b) ? 0 : (($a < $b) ? 1 : -1 ) ;});
?>
Run Code Online (Sandbox Code Playgroud)
但在服务器上它会抛出一个错误:
解析错误:语法错误,意外T_FUNCTION,期待')'
对于这一行:
array_map(function($var){}, $matches_array_1);
Run Code Online (Sandbox Code Playgroud)
我的localhost WAMP PHP版本是5.4.3
我的服务器PHP版本是5.2.17
我想更改代码,以便它适用于这两种环境.
谢谢你的建议.
我需要使用PHP生成这样的东西:
******
*********
****
***********
******
********
*******
*********
*******
**********
********
******
********
Run Code Online (Sandbox Code Playgroud)
使用PHP.
所以,如果我到目前为止我有这个代码:
<?php
$character = "*"; //character that will be used in generated strings
$min = "4"; //minimum characters for a generated string
$max = "12"; //maximum characters for a generated string
?>
Run Code Online (Sandbox Code Playgroud)
为rand()和字符串的echo写下一部分代码的有效方法是什么?
可能重复:
除了允许之外,删除所有HTML标记
我有这个代码:
<?php echo strip_tags($row->message); ?>
Run Code Online (Sandbox Code Playgroud)
现在,我需要为href html标记添加异常<a>,因为现在所有标记都被抛弃了.
提前致谢.
我有这个数组:
$myArray = (
[0] => 'First',
[1] => 'Second',
[2] => 'Third',
[3] => 'Fourth'
);
Run Code Online (Sandbox Code Playgroud)
我需要得到这个:
$myArray = (
[0] => 'Fourth',
[1] => 'Third',
[2] => 'Second',
[3] => 'First'
);
Run Code Online (Sandbox Code Playgroud)
因此,与原始数组相比,我可以以相反的顺序将其存储在我的数据库中.
我试过krsort($myArray);但结果不是我想要的,因为它创建了这样的东西:
$myArray = (
[3] => 'Fourth',
[2] => 'Third',
[1] => 'Second',
[0] => 'First'
);
Run Code Online (Sandbox Code Playgroud)
我希望键保持原始阵列.
问题在于我不能使用arsort()等对字母进行排序,因为它们是不同的(不同的字符串,没有任何意义或订单系统).
知道怎么做吗?