mysql - string conversion to array by commaseparated using php -
I am finding it difficult to get value from using curl from the URL doing online work fine, but the problem here it's like giving United string - the first URL was a value and the URL to return back with 5 values total to six the values such as, update You have written in the comments, that there is no number in the last few variables. It is impossible to predict the delimiters in that case As long as you do not know that If you do not, then the answer is: you can not, sorry, . As suggested in Shahrukh , try to send a parameter to another page / subpage / script to use json. Every variable has finished with a number, you can try this solution: (I think with each variable passed the number Is finished, so you should be careful and ensure that this is the correct format, that data will always be sent). will print out: I hope it However, I think you should change some of your application logic and for example If you want to get rid of the "test", then you can do for example: But remember that when you change them at the same time, then modify the array. "testdata1testdata2testdata3testdata4testdata5testdata6testdata7" I How to separate strings from commas There is a need to insert these data for storage like mysql.
function data ($ url, $ v) {foreach ($ url = & gt; $ key as in $ url) {$ curl = curl_init (); Curl_setopt ($ curl, CURLOPT_URL, $ key); Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ curl, CURLOPT_CONNECTTIMEOUT, 20); Curl_setopt ($ curl, CURLOPT_USERAGENT, $ useragent); $ Str = curl_exec ($ curl); Curl_close ($ curl); $ Html = str_get_html ($ str); Foreach ($ html-> Search ('.name') as $ element) {$ grab = $ element-> Internal text; $ Sql = $ this- & gt; Db- & gt; Ready ("update table SET word = 'grab $' where url = '$ v [$ url]'"); }}}
Function Each ($ matches) {Returns $ matches [1]. ','; } $ Input = 'testdata1testdata2testdata3testdata4testdata5testdata6testdata7'; '; $ Input = preg_replace_callback ("| (\ d +) |", "every", $ input); $ Input = explosion (',', rtrim ($ input, ", ')); Print_r ($ input);
Array ([0] = & gt; testdata1 [1] = & gt; testdata2 [2] = & gt; testdata3 [3] = & gt; testdata4 [4] = & gt; testdata5 [5] = & gt; testdata6 [6] = & gt; testdata7)
foreach ($ input = $ as input = $ value) $ Input [$ key] = substr ($ value, 4);
Comments
Post a Comment