Comments (7)
That's simple enough check not to have a special wrapper for it:
if (\trim($string) === '') {
from yii-core.
That's simple enough check not to have a special wrapper for it:
if (\trim($string) === '') {
What about null
? What about type casting (int, obj)? I use such function all the time and think it is quite useful.
from yii-core.
Wow...
It may be useful to know that trim() returns an empty string when the argument is an unset/null variable.
I didn't know that! You are right, isEmpty
now useless.
from yii-core.
And one more question - I used to use helper ArrayHelper::isSet($array, $path)
which takes an array and a key path and check if the path exists.
isSet([
[
'one' => 'One',
'two' => [
'label' => 'Two',
'value' => 2
],
],
],
'0.two.label') // true
Can I do the same by native php function?
from yii-core.
No, that you cannot do with native function.
from yii-core.
Actually he can do this
isset($arr[0]['two']['label'])
It checks for all keys and when any defined does not exist it returns false, I don't see a reason to use dot syntax here
from yii-core.
BTW, I like null operator on similar case:
return $array['foo']['boo'] ?? false;
from yii-core.
Related Issues (20)
- 我认为yii3最应该解决的就是composer包过大的问题 HOT 2
- Should not require yii-web HOT 11
- Enhancement: BaseJson::decode supports decode options HOT 1
- Discuss: Do we still need controllers? HOT 2
- can't visit yii forum site HOT 1
- Review helpers naming and usage HOT 33
- Url::ensureScheme should fail hard for non absolute paths HOT 2
- What is the current dependency between repo? HOT 20
- Yii3 assets path not correctly reference if installed in subfolder HOT 2
- SOLID compliance HOT 3
- cannot use @web or @webroot in config. HOT 53
- Deal with relative links in Formatter::asUrl() HOT 4
- Nested model attribute label issue HOT 12
- Custom reference syntax to class or class member in comments make impossible to navigate in IDE HOT 19
- Change namespace to Yiisoft\Core? HOT 8
- When will yii3 be released? HOT 1
- Request to separate FileHelper from yii-core HOT 19
- Pack requirements checker into separate package HOT 1
- Repo merges into a repo and then splits HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii-core.