小编Con*_*son的帖子

查找字符串的一部分并输出整个字符串

我想找到一个字符串的一部分,如果true我想输出它找到的整个字符串.

以下是一个例子:

$Towns = "Eccleston, Aberdeen, Glasgow";
$Find = "Eccle";

if(strstr($Find, $Towns)){
    echo outputWholeString($Find, $Towns); // Result: Eccleston.
}
Run Code Online (Sandbox Code Playgroud)

如果有人能够阐明如何做到这一点,并且记住它不会是静态值; 在$Towns$Find变量将被动态地分配在我住的脚本.

php string strpos

5
推荐指数
1
解决办法
93
查看次数

基于 JSON 对象中的值的 Laravel 关系

我有两个模型需要关联,一个Users模型和一个Prices模型。在我的Prices模型中有一个JSON object持有ID用户的 ,我想知道我是否可以Prices使用模型中的ID哪个与我的表相关联Prices

我知道你可以使用 angetAttribute然后像这样返回用户,但我想知道是否有$this->hasOne()你可以使用的方法?

例如

JSON

{user_id: 1, other_values:"in the object"}

价格模型

class Prices extends Model { 

    /* Prices has the column 'object' which has the JSON object above */

    protected $casts = ['object' => 'array'];

    public function user(){
        return $this->hasOne("App\User", $this->object->user_id, "id"); /* ! Example ! */
    }
}
Run Code Online (Sandbox Code Playgroud)

php laravel

5
推荐指数
1
解决办法
6255
查看次数

表字段中的变量名称不起作用

我在为游戏编写代码时遇到了一个问题.似乎我不能在语句中使用变量;

local Username = "Cranavvo"
game.Players.Username:BreakJoints() -- Kills the player
Run Code Online (Sandbox Code Playgroud)

输出告诉我"没有这样的用户''用户名'"应该是"Cranavvo".

lua roblox lua-table

4
推荐指数
1
解决办法
808
查看次数

样式选择文本溢出

试图找出样式选择框的问题.它被包裹在一个带背景的div中,以创建一个蒙版外观.

当<option>中的文本太多时,它会溢出到按钮上

当输入中的文本太多时,它将溢出到按钮中.

HTML:

<div class="styled-select">
    <select  class="form-control required" name="address" disabled>
        <option style="" value="">Please Select Address</option>
    </select>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

    .styled-select select {
    font-family: "Circular", Helvetica, Arial, sans-serif;
    font-size: 18px;
    background: transparent;
    width: 100%;
    padding: 15px;
    font-size: 16px;
    line-height: 1;
    border: 0;
    height: 50px;
    border-radius: 10px;
    -webkit-appearance: none;
    padding-right: 10%;
}

.styled-select { 
    width: 100%; 
    overflow: hidden; 
    background: url(../images/bg/down-arrow.jpg) no-repeat right #FFF; 
    background-size: 60px; 
    height: 50px; 
    border-radius: 10px; 
}

@media (min-width: 768px) {
    .styled-select select {
    font-family: "Circular", Helvetica, Arial, sans-serif; …
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap-3

4
推荐指数
1
解决办法
3393
查看次数

在用户自制的功能中使用"或死"

有没有办法or die()在内置函数中创建函数时使用mysql_connect() or die("There was an error connecting to MySQL!")

php

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

标签 统计

php ×3

css ×1

html ×1

laravel ×1

lua ×1

lua-table ×1

roblox ×1

string ×1

strpos ×1

twitter-bootstrap-3 ×1