I think DNS is the only way....
Just throwing it to the field to see if anyone had any bright ideas..!
not trying to set two ip address on same machine.. just want to do away with having to get users to change IP when coming in the office.. and after having left the office.. ie.. I leave the office.. change the IP on the application to 80.*.*.*.. get the data.. next day come back in theoffice change to 192.168.*.* get the data.. I told them to just change the address.. ! they are not quite so keen!!
There are different ways to delete an array element, where some are more useful for some specific tasks than others.
Also if you have the value and don't know the key to delete the element you can use
rray_search() to get the key.
Note that when you use
unset() the array keys won't change/reindex. If you want to reindex the keys you can use
unset() which will convert all keys to numerical enumerated keys starting from 0.
<?php $array = [0 => "a", 1 => "b", 2 => "c"]; unset($array); //↑ Key which you want to delete ?>
[  => a  => c ]
If you use
rray_splice() the keys will be automatically reindexed, but the associative keys won't change as opposed to
rray_values() which will convert all keys to numerical keys.
rray_splice() needs the offset, not the key! as the second parameter.
<?php $array = [0 => "a", 1 => "b", 2 => "c"]; rray_splice($array, 1, 1); //↑ Offset which you want to delete ?>
[  => a  => c ]
array_splice() same as
unset() take the array by reference, and this means you don't want to assign the return values of those functions back to the array.
If you want to delete multiple array elements and don't want to call
rray_splice()multiple times you can use the functions
rray_diff_key() depending on if you know the values or the keys of the elements which you want to delete.
If you know the values of the array elements which you want to delete, then you can use
rray_diff(). As before with
unset() it won't change/reindex the keys of the array.
<?php $array = [0 => "a", 1 => "b", 2 => "c"]; $array = rray_diff($array, ["a", "c"]); //└────────┘→ Array values which you want to delete ?>
[  => b ]
If you know the keys of the elements which you want to delete, then you want to use
rray_diff_key(). Here you have to make sure you pass the keys as keys in the second parameter and not as values. Otherwise, you have to flip the array with
rray_flip(). And also here the keys won't change/reindex.
<?php $array = [0 => "a", 1 => "b", 2 => "c"]; $array = rray_diff_key($array, [0 => "xy", "2" => "xy"]); //↑ ↑ Array keys which you want to delete ?>
[  => b ]
Also if you want to use
rray_splice() to delete multiple elements with the same value you can use
rray_keys() to get all the keys for a specific value and then delete all elements.