小编Sai*_*son的帖子

如何用星号替换某些字符

我有一个简单的任务与PHP,但由于我不熟悉正则表达式或其他东西......我不知道我将要做什么.

我想要的是非常简单的......

假设我有这些变量:

$Email = 'john@example.com'; // output : ****@example.com
$Email2 = 'janedoe@example.com'; // output : *******@example.com
$Email3 = 'johndoe2012@example.com'; // output : ***********@example.com

$Phone = '0821212121'; // output : 082121**** << REPLACE LAST FOUR DIGIT WITH *
Run Code Online (Sandbox Code Playgroud)

如何用PHP做到这一点?谢谢.

php

3
推荐指数
1
解决办法
7567
查看次数

这个jQuery不适用于Mac,但适用于Linux和Windows

我的浏览器在这里有一些奇怪的经历.以下代码已上传到此网址:http://roberthanson.net/index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function($) {
        $('ul li').click(function() {
            $('input#shareto').val($(this).data('val'));
        });
    });?
</script>
</head>

<body>

<form>
<ul>
<li data-val="0-1">
<a href="#" title="" class="selected"><span class="to-admin">Administrator</span></a>    
</li>

<li data-val="1-1">
<a href="#" title=""><span class="to-finance">Finance</span></a>    
</li>

<li data-val="1-0">
<a href="#" title=""><span class="to-technician">Technician</span></a>
</li>

<li data-val="0-0">
<a href="#" title=""><span class="to-lawyer">Legal</span></a>    
</li>
</ul>
<input id="shareto" type="text" value="1-0" name="shareto">
?
?</form>????????

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我在Linux上使用Microsoft …

php macos jquery

3
推荐指数
1
解决办法
1742
查看次数

PHP在00 - 29之间生成随机数

可能重复:
在PHP中格式化带前导零的数字

我的值在00 - 29之间,需要使用PHP随机选择.我尝试使用rand()函数,但它给了我0 - 29.而不是00,01,02,03 ...等.

如何从PHP随机获得00 - 09而不是0 - 9?谢谢.

php

3
推荐指数
1
解决办法
6845
查看次数

如何显示和隐藏UIPickerView像iOS键盘?

我有这个代码默认隐藏UIPickerView:

- (void)viewDidLoad
{
    [super viewDidLoad];
    [_memberList setAlpha:0];
}
Run Code Online (Sandbox Code Playgroud)

这个代码在按下按钮时显示UIPickerView:

- (IBAction)buttonChooseMember {    
    [UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{
        [_memberList setAlpha:1];
    } completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

最后一件事是,当用户点击任何地方时隐藏键盘:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    for (UIView * txt in self.view.subviews){
        if ([txt isKindOfClass:[UITextField class]]) {
            [txt resignFirstResponder];
        }else if ([txt isKindOfClass:[UIPickerView class]]) {
            [UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{
                [_registerMLMList setAlpha:0];
            } completion:nil];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但所有这些只是给我'出现'动画,因为它只是将Alpha值从0改为1(反之亦然).不像iOS键盘那​​样向上滑动或向下滑动.

我尝试使用下面的动画在我的UIPickerView上拥有iOS键盘外观:

- (IBAction)hidePicker {

    UIPickerView *pickerView = [[UIPickerView alloc] init]; // default frame is set
    float pvHeight = …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

3
推荐指数
1
解决办法
9304
查看次数

MySQL更新IF(ROW_COUNT()= 0)

我有这个SQL:

UPDATE gcd_data 
SET post_title = 'Hello World', 
    post_content = 'How Are You?',  
    post_date_gmt = '', 
    post_modified_gmt = '',
    post_url = 'www.google.com', 
    post_type = 'product'
WHERE gcd_id='1024'
IF (ROW_COUNT() = 0)
INSERT INTO gcd_data (gcd_id, post_title, post_content, post_date_gmt, 
                   post_modified_gmt, post_url, post_type) 
VALUES ('1024', 'Hello World', 'How Are You?', '', '', 'www.google.com', 'product')
Run Code Online (Sandbox Code Playgroud)

它给我这样的错误:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF (ROW_COUNT() …
Run Code Online (Sandbox Code Playgroud)

mysql sql

3
推荐指数
1
解决办法
690
查看次数

Bootstrap .btn 在 Safari 上看起来不同

我有这个 HTML 代码:

<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  <a href="poweron.php" type="button" class="btn btn-danger text-white">Power On</a>
</div>
Run Code Online (Sandbox Code Playgroud)

这是它在 Safari 和 Chrome 上的样子:

在此输入图像描述

为什么电源按钮看起来“灰色”,并且在 Safari 上大小不同,但在 Chrome 上却按我的预期工作?如何让它看起来和谷歌浏览器上的一模一样?

html css bootstrap-4

3
推荐指数
1
解决办法
1142
查看次数

此JavaScript函数单独工作,但不与其他JavaScript函数一起使用

我有这个javascript:

<script type="text/javascript">
$(document).ready(function($) {
        $('#target-share ul li').click(function() {
            $('input#shareto').val($(this).data('val'));
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

它确实像我预期的那样工作.但是当我添加另外一个javascript来做下拉动画时,那个javascript就不再起作用了:

<script type="text/javascript">
$(document).ready(function() {
    $("#select-shareto a").click(function () {
        var newClass = $(this).find("span").attr('class');
        var newText = $(this).find("span").text();
        $("#select-shareto a").removeClass("selected");
        $(this).addClass("selected");
        $("a#to-chosen span").removeClass().addClass(newClass).text(newText);
        $("a#to-chosen").toggleClass("opened");
        $('#select-shareto').slideToggle('fast');
        return false;
    });

    $('a#to-chosen').click(function() {
        $(this).toggleClass("opened");
        $('#select-shareto').slideToggle('fast', function() {
            // Animation complete.
        });
    });
});
</script>
Run Code Online (Sandbox Code Playgroud)

那些javascript实际上影响了这个HTML代码:

<div id="target-share">
<a href="#" title="" id="to-chosen" class="default"><span class="to-admin">Admin</span></a>
<ul id="select-shareto">
<li data-val="0-1">
<a href="#" title="" class="selected"><span class="to-Finance">Finance</span></a>
</li>
<li data-val="1-1">
<a href="#" title=""><span class="to-admin-private">Admin Private</span></a>
</li> …
Run Code Online (Sandbox Code Playgroud)

javascript php jquery

2
推荐指数
1
解决办法
95
查看次数

在'const _strong id'类型的对象上找不到属性'tag'

tag为我的UILabel 设置了StoryBoard属性检查器,我的ViewController.m上有这个代码:

for (id subview in [[self view] subviews]) 
{
    if (subview.tag==1) 
    {
        [subview setFont:[UIFont fontWithName:@"Raleway-ExtraLight" size:12]];
    } else if (subview.tag==2) {
        [subview setFont:[UIFont fontWithName:@"Raleway-ExtraLight" size:28]];
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行我的代码时,我收到此错误:

在'const _strong id'类型的对象上找不到属性'tag'

我错过了什么?谢谢......

objective-c ios

2
推荐指数
2
解决办法
1660
查看次数

如何在UILabel上为Underline创建属性?

我的代码已经有了这个属性,但是如何为下划线添加属性?

NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys: 
boldFont, NSFontAttributeName, foregroundColor, NSForegroundColorAttributeName, nil];
Run Code Online (Sandbox Code Playgroud)

objective-c nsattributedstring ios

2
推荐指数
1
解决办法
5504
查看次数

jQuery LazyLoad 用于从 Ajax 加载新图像

我有这个代码适用于第一次加载的图像:

<script>
    $( document ).ready(function() {
        $("img.lazy").lazyload({
            effect : "fadeIn",
            threshold : 200
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

但对于从 AJAX 加载的新图像,它不起作用。我通过使用事件委托来阅读,它可以应用于新加载的图像。

https://learn.jquery.com/events/event-delegation/

但是当我尝试将代码更改为:

<script>
    $( document ).ready(function() {
        $("img.lazy").lazyload( function(event) {
            effect : "fadeIn",
            threshold : 200
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

它使所有延迟加载不再起作用。在这种情况下如何正确附加事件委托?谢谢。

jquery

2
推荐指数
1
解决办法
4034
查看次数

标签 统计

php ×4

ios ×3

jquery ×3

objective-c ×3

bootstrap-4 ×1

css ×1

html ×1

javascript ×1

macos ×1

mysql ×1

nsattributedstring ×1

sql ×1