2011-01-04 5 views
0

배열은 "\ /"페이지의 자바 스크립트 화면 스크래핑에서 생성되므로 다음 "\ /"배열을 포함하고 있습니다. 단지 "/"이 될 수 있습니다." /"를 "/"로 바꾸십시오.

Array ( 
    [0] => 1 Jet Black 
    [1] => 1B\/350T Black With Copper Tips 
    [2] => 1B\/BGT Black With Burgandy Tips 
    [3] => 1b Natural Black 
    [4] => 2 Darkest Brown 
    [5] => 4 Chocolate Brown 
    [6] => 27 Strawberry Blonde 
) 

내가 생각할 수있는 최선가 될 것이다 :

$a = array("1B\/BGT Black With Burgandy Tips", "1B\/350T Black With Copper Tips"); 

foreach ($a as $key => $itsvalue) { 
    $a[$key] = strreplace("\\\/","\/",$itsvalue) 
} 

답변

0
여기에 배열의

코드는 다음과 같아야합니다. -

<?php 
$a = array("1B\/BGT Black With Burgandy Tips", "1B\/350T Black With Copper Tips"); 

foreach ($a as $key => $itsvalue) { 
    $a[$key] = str_replace("\/","/",$itsvalue) 
} 
?> 

희망적입니다.

0

잘 작동합니다 그 :

$a = array("1B\/BGT Black With Burgandy Tips", "1B\/350T Black With Copper Tips"); 

foreach ($a as $key => $itsvalue) { 
    $a[$key] = str_replace("\/","/", $itsvalue); 
} 

print_r($a); 

결과 :

Array ([0] => 1B/BGT Black With Burgandy Tips [1] => 1B/350T Black With Copper Tips) 
관련 문제