如何从包含数字,字母等的字符串中获取字节数组?如果您熟悉Java,我正在寻找getBytes()方法的相同功能.
我尝试了一个像这样的片段:
for($i = 0; $i < strlen($msg); $i++){
$data.=ord($msg[$i]);
//or $data[]=ord($msg[$1]);
}
Run Code Online (Sandbox Code Playgroud)
但没有成功,所以任何形式的帮助将不胜感激.
PS:为什么我需要这个!?好吧,我需要通过fputs()将一个字节数组发送到用Java编写的服务器...
我有以下查询:
$query = Doctrine_Query::create()
->from('Member m')
->where("m.type='1'")
->andWhere("m.name LIKE '%$term%'")
->orWhere("m.surname LIKE '%$term%'")
->orWhere("m.company LIKE '%$term%'")
->orderBy('id DESC');
Run Code Online (Sandbox Code Playgroud)
但它不像我想的那样工作 - 它忽略了type列.
我需要的是结果集m.type=1此查询中的其他字段和其他一些字段LIKE 'something'.
我需要打印一些数据(格式有点奇怪).我用PHP编写了if($ num%10 == 9),但我无法获得正确的输出.
所以看看这个例子.我们在文件夹中有x个文件.对于这个例子,x = 36.X总是众所周知的.
输出应如下所示:
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
10
11
...
19
1a
...
1f
20
...
24
Run Code Online (Sandbox Code Playgroud)
对于这么长的"清单"感到抱歉,但我相信你现在知道我需要什么.因此,在以9结尾的每个数字之后,我们有num(a,b,c,d,e,f),然后是数字,它跟在前面的数字后面,结尾是9.(例如3a ... 3f,40..49).最重要的是印刷线的数量必须等于x.
如果可能的话,我更喜欢PHP或Java代码,但我会非常感谢任何帮助.
好的,我正在监视某个文件并对该文件进行一些tail -f分析.但是,另一个应用程序具有特定的逻辑,它将在下一个日期甚至之前创建一个新文件.
我正在寻找一种方法来检测新创建的文件(主机是linux机器),然后不重新启动我当前的go服务来开始拖尾新创建的文件.
这是我当前拖尾"当前文件"的逻辑:
func main(){
currentTime := time.Now().Local()
currentFileName := strings.Replace(currentTime.Format("2006-01-02"), "-","",2)
newFileName := currentFileName + "_1111.log.txt"
//using github.com/hpcloud/tail for tail
t, err := tail.TailFile("/var/log/"+newFileName, tail.Config{Follow: true, ReOpen: true})
for line := range t.Lines {
//fmt.Println("Line is:", line.Text)
//check do we have error inside new line
if strings.Contains(strings.ToLower(line.Text), "mfc"){
fmt.Println("MFC located: ", line.Text)
//now send e-mail to all interested parties
//sendEmail(line.Text)
}
}
fmt.Println(err)
}
Run Code Online (Sandbox Code Playgroud)
当前文件而不是20161219_1111.log可以是20161219_2222.log或类似,并在第二天从20161220_1111.log等开始.
任何提示都是受欢迎的.
当我运行此代码时:
foreach ($tree as $node) {
echo str_repeat(' ', $node->tree_depth * 4) . $node->id . PHP_EOL;
}
Run Code Online (Sandbox Code Playgroud)
我得到格式良好的文字,如:
Food
Fruit
Red
Cherry
Strawberry
Cool
Not cool
Yellow
Banana
Meat
Beef
Pork
Run Code Online (Sandbox Code Playgroud)
但我想创建一个列表<ul><li>...:
我尝试过:
echo '<ul>';
$prev_depth = 0;
foreach($table->fetchTree() as $row) {
if ($row->tree_depth > $prev_depth) {
echo '<li><ul>';
} else if ($row->tree_depth < $prev_depth) {
echo '</li></ul>';
}
echo '<li>' . $row->name . '</li>';
$prev_depth = $row->tree_depth;
}
echo '</ul>';
Run Code Online (Sandbox Code Playgroud)
但我有一些额外的ul标签等等.我失去了2天,如果你能帮助我,请在这里发帖...
我正在寻找用java编写的Apache Lucene网络爬虫(如果可能或任何其他语言).爬虫必须使用lucene并创建一个有效的lucene索引和文档文件,所以这就是为什么nutch被淘汰的原因......
有没有人知道这样的网络爬虫存在,如果答案是肯定的,我可以找到它.TNX ...