I have search through so many questions but I couldn"t find it.I have string lượt thích this:
Ab2cds value=284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134What I want to vày is get all values only in output đầu ra like:
284t810 39h1047 3700p134I used substr và strpos combine khổng lồ get value but it only removes portion of data ahead of first "value=" so output is like:
284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134I just want to lớn delete everything else and keep only numbered value which is after "value="
Sorry if there is any confusion. Using darkedeneurope.com for first time.
Bạn đang xem: Strval

use this code:with this code you get any strings that they are after value=.I think this is the easiest solution.
$str = "b2cds value=284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134";preg_match_all("#value=(<^s>+)#", $str, $matches);echo implode(" ", $matches<1>);
Kesh : s means space. <^s> means everything except space. And + means at least one char. And the () around it is for selecting the string so we can use it after the operation. (<^s>+) means select everything except space & put them khổng lồ the $matches

Do it via regular expression
$str = "b2cds value=284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134";preg_match_all("/value=(<^s>+)/", $str, $matches);echo implode(" ", $matches<1>);Here you can see demo

You could use a lookahead to find all value= & take all characters after that until a space character is encountered then implode the results using a space.
$string = "Ab2cds value=284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134";preg_match_all("/(?=value=(<^s>+))/", $string, $matches);$result = implode(" ", $matches<1>);The output đầu ra is
284t810 39h1047 3700p134

Sticking khổng lồ substr() & strpos() you can vị the following as long as you can trust the format of the data.
Xem thêm: Sinh Con Trai Sinh Năm 2019 Hay Và Ý Nghĩa Nhất, Hợp Phong Thủy
$s = "Ab2cds value=284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134";echo "Input string: $s ";$out = "";$offset = 0;while ( $offset = strpos($s,"=",$offset) ) $end = strpos($s," ",$offset); if ( $end ) $out .= substr($s,$offset+1,$end-$offset); else $out .= substr($s,$offset+1); $offset++;echo "Output string: $out ";This will yield the following:
Input string: Ab2cds value=284t810 shfn4wksn value=39h1047 hs2krj8dne value=3700p134Output string: 284t810 39h1047 3700p134I"m guessing that perhaps you wanted to use a strpos() based solution for efficiency purposes.

Try this
$data = "Ab2cds value=284810 shfn4wksn value=391047 hs2krj8dne value=3700134";$array_data = explode(" ", $data);foreach ($array_data as $array_dat) $data_list<> = strstr($array_dat, "=");foreach ($data_list as $key => $value) $array<$key> = str_replace("=", "", $value);var_dump(array_filter($array));OUTPUT
array(3) <1>=> string(6) "284810" <3>=> string(6) "391047" <5>=> string(7) "3700134"
Thanks for contributing an answer to Stack Overflow!
But avoid …
Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.
Post Your Answer Discard
By clicking “Post Your Answer”, you agree to lớn our terms of service, privacy policy và cookie policy
Site kiến thiết / biểu tượng logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.4.21.42004
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.