Convert PHP array string into array -
if execute var_dump(array($output))
shows
array(1) { [0]=> string(573) " __(developer’s must have gray cardigan|:89.77,gravityforms), __(polka dots blue dress|:55.45,gravityforms), __(classic brown leather bag orange details|:66.84,gravityforms), __(cycling pack steel blue|:360.00,gravityforms), __(classic brown leather bag orange details|:,gravityforms), __(the black cat winter jacket|:254.45,gravityforms), __(split slit gold threading cardi|:165.74,gravityforms), __(slim fit pants|:85,gravityforms), __(get complete wordpress developer outfit|:65.55,gravityforms), __(biodiesel cardigan dreamcatcher|:175.00,gravityforms)," }
but want this
array(10) { [0]=> string(44) "developer’s must have gray cardigan|:89.77" [1]=> string(28) "polka dots blue dress|:55.45" [2]=> string(52) "classic brown leather bag orange details|:66.84" [3]=> string(31) "cycling pack steel blue|:360.00" [4]=> string(47) "classic brown leather bag orange details|:" [5]=> string(35) "the black cat winter jacket|:254.45" [6]=> string(39) "split slit gold threading cardi|:165.74" [7]=> string(18) "slim fit pants|:85" [8]=> string(50) "get complete wordpress developer outfit|:65.55" [9]=> string(39) "biodiesel cardigan dreamcatcher|:175.00" }
how can this?
use array_push
$outputarr = array(); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $price = get_post_meta(get_the_id(), '_regular_price', true); array_push($outputarr, ' __(' . get_the_title() . '|:' . $price . ',gravityforms)'); } } var_dump($outputarr);
hope helps
if want use array further make foreach
, execute
Comments
Post a Comment