从数组php中删除某些String

时间:2018-01-30 13:35:45

标签: php mysql split

我希望借助add_filter( 'woocommerce_checkout_fields', 'override_default_billing_phone'); function override_default_billing_phone($fields){ global $woocommerce; $country = $woocommerce->customer->get_country(); //your country goes here for example 'AE' for UAE if($country == 'AE'){ $fields['billing']['billing_phone']['default'] = '+971'; //Here is the code for billing phone } return $fields; } str_replace中的PHP函数摆脱该字符串,但我无法工作。有人能帮助我吗?

$sql = "SELECT data from users";
  $result = $mysqli->query($sql);
  $widgets = [];
while($row = mysqli_fetch_array($result))
{
    $widgets[] = $row;
}

$alignment = explode("//",serialize($widgets));

for($i = 0; $i<count($alignment); $i++){
  str_replace("a:3:{i:0,:a:2:{:i:0;s:31;q}")
}

  ?>

2 个答案:

答案 0 :(得分:0)

http://php.net/manual/en/function.str-replace.php

所述

php_replace带3个参数

$replaced = str_replace(search, replaced_by, initial_string, [&replaced]);

答案 1 :(得分:0)

为了清晰起见,请参阅str_replace功能,并更改您的代码,如下所示:

public  class BeaconSingletone implements BeaconConsumer {

    private static BeaconSingletone instance;

    private final org.altbeacon.beacon.BeaconManager beaconManager2;
    private  ArrayList<BeaconThin> listNearBeacons = new ArrayList<>();




    BeaconRegion region = new BeaconRegion("ranged region",
                              UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null);

    private List<EventInterface> listeners = new ArrayList<EventInterface>();

    private BeaconSingletone()
    {

        beaconManager2 = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(ar_activity.get());
        // To detect proprietary beacons, you must add a line like below corresponding to your beacon
        // type.  Do a web search for "setBeaconLayout" to get the proper expression.
         beaconManager2.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
        beaconManager2.bind(this);



    public static BeaconSingletone getInstance() {
        if(instance == null) {
            instance = new BeaconSingletone();
        }
        return instance;
    }
    private void showNotification(Region region, final List<Beacon> list) {
        listNearBeacons.clear();
        listNearBeacons.add(new BeaconThin(3514,7580,-1));
        for (Iterator<EventInterface> i = listeners.iterator(); i.hasNext(); ) {
            EventInterface item = i.next();
            //item.NewBeaconFound(list.get(0).getMajor(),list.get(0).getMinor(),Utils.computeAccuracy(list.get(0)));
            item.NewBeaconsFound(listNearBeacons);
        }
        return;




    }



    @Override
    public void onBeaconServiceConnect() {
        beaconManager2.addRangeNotifier(new RangeNotifier() {
            @Override
            public void didRangeBeaconsInRegion(Collection<org.altbeacon.beacon.Beacon> beacons, org.altbeacon.beacon.Region region) {
                if (beacons.size() > 0) {
                    Log.i("BeaconManager", "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");
                }
            }
        });
        try {
            beaconManager2.startRangingBeaconsInRegion(new org.altbeacon.beacon.Region("mybeacons", null, null, null));
        } catch (RemoteException e) {    }{


    }

    }

    @Override
    public Context getApplicationContext() {
        return ar_activity.get();
    }

    @Override
    public void unbindService(ServiceConnection serviceConnection) {
        ar_activity.get().unbindService(serviceConnection);
    }

    @Override
    public boolean bindService(Intent intent, ServiceConnection serviceConnection, int i) {
        return ar_activity.get().bindService(intent, serviceConnection, i);
    }
}