If I have an array $abc=[0,0,0,1,0,2];
how to change it to $abc=[1,2]; (remove all 0), is there php function can handle that? thanks.
michael123 0
Junior Poster in Training
Recommended Answers
Jump to PostIf I have an array $abc=[0,0,0,1,0,2];
how to change it to $abc=[1,2]; (remove all 0), is there php function can handle that? thanks.Im wondering...
Is this any faster?
<?php function removeVal($array, $val) { $string = implode(',', $array); $new_string = str_replace($val.',', ',', $string); $new_array = explode(',', …
Jump to PostIf I have an array $abc=[0,0,0,1,0,2];
how to change it to $abc=[1,2]; (remove all 0), is there php function can handle that? thanks.Heres a way of doing this that seems to be the most efficient.
The $new_array also retains its key values.function removeVals($var) { return …
All 6 Replies
guideseeq 0
Junior Poster in Training
pc2forum 0
Newbie Poster
guideseeq 0
Junior Poster in Training
pc2forum 0
Newbie Poster
digital-ether 399
Nearly a Posting Virtuoso Team Colleague
digital-ether 399
Nearly a Posting Virtuoso Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.