logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ strval

Strval

by Admin _ April 25, 2022

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!

Please be sure lớn answer the question. Provide details và share your research!

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.

Share Tweet Linkedin Pinterest
Previous Post

Php onclick function with "" and '' does not work

Next Post

Submit a form without page refresh using jquery

CÙNG CHUYÊN MỤC

form register php

Form register php

09/04/2021
fantastic blog (cms) in php with source code

Fantastic blog (cms) in php with source code

28/04/2021
validate form php javascript

Validate form php javascript

28/04/2021
http diendanlequydon com viewtopic php style 6

Http diendanlequydon com viewtopic php style 6

28/04/2021
jquery ajax post method

Jquery ajax post method

23/05/2022
browse /xampp windows/5

Browse /xampp windows/5

23/05/2022
top 17 date_default_timezone_set('asia/ho_chi_minh') hay nhất 2022

Top 17 date_default_timezone_set('asia/ho_chi_minh') hay nhất 2022

23/05/2022
how to install the lamp stack on centos 7

How to install the lamp stack on centos 7

21/05/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Sửa lỗi plugin bị chặn

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.